Files
GitHawk/Classes/Views/UIScrollView+ScrollToBottom.swift
2017-07-24 13:56:24 -06:00

22 lines
522 B
Swift

//
// UIScrollView+ScrollToBottom.swift
// Freetime
//
// Created by Ryan Nystrom on 7/24/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
extension UIScrollView {
func scrollToBottom(animated: Bool) {
let inset = contentInset
let contentHeight = contentSize.height
let viewportHeight = bounds.height
let offset = contentHeight - inset.bottom + inset.top - viewportHeight
setContentOffset(CGPoint(x: 0, y: offset), animated: animated)
}
}