Skip to content

Instantly share code, notes, and snippets.

@max-potapov
Created October 19, 2015 11:17
Show Gist options
  • Save max-potapov/4ffe78c7ee61063b4ef4 to your computer and use it in GitHub Desktop.
Save max-potapov/4ffe78c7ee61063b4ef4 to your computer and use it in GitHub Desktop.
extension UIViewController {
func adjustTableViewInsects(tableView: UITableView?) {
guard let tableView = tableView, let navigationController = navigationController else {
return
}
automaticallyAdjustsScrollViewInsets = false
let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height
let navigationBarHeight = navigationController.navigationBar.bounds.size.height
tableView.contentInset.top = statusBarHeight + navigationBarHeight
tableView.scrollIndicatorInsets = tableView.contentInset
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment