Created
August 4, 2016 14:56
-
-
Save christ776/1e30b3d0b3b8aa423f475ff483260bee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol TableViewFooter:class { | |
var footerActivityIndicator:UIActivityIndicatorView! {get set} | |
var tableView:UITableView! {get set} | |
func setupTableViewFooter() | |
} | |
extension TableViewFooter { | |
func setupTableViewFooter() { | |
let footerView = UIView(frame:CGRectMake(0, 0, 0, 44)) | |
// set up activity indicator | |
footerActivityIndicator = UIActivityIndicatorView(frame:CGRectMake(0, 0, 44, 44)) | |
footerActivityIndicator.translatesAutoresizingMaskIntoConstraints = false | |
footerActivityIndicator.hidesWhenStopped = true | |
footerActivityIndicator.activityIndicatorViewStyle = .Gray | |
footerView.addSubview(footerActivityIndicator) | |
// Center Vertically | |
let centerYConstraint = NSLayoutConstraint(item:self.footerActivityIndicator,attribute:.CenterY,relatedBy:.Equal, | |
toItem:footerView,attribute:.CenterY,multiplier:1.0,constant:0.0) | |
footerView.addConstraint(centerYConstraint) | |
// Center Horizontally | |
let centerXConstraint = NSLayoutConstraint(item:self.footerActivityIndicator,attribute:.CenterX,relatedBy:.Equal, | |
toItem:footerView, attribute:.CenterX,multiplier:1.0,constant:0.0) | |
footerView.addConstraint(centerXConstraint) | |
tableView.tableFooterView = footerView | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment