Skip to content

Instantly share code, notes, and snippets.

@hudinwal
Created August 15, 2016 12:19
Show Gist options
  • Save hudinwal/228a448ad6654ae89c4dc2c636591905 to your computer and use it in GitHub Desktop.
Save hudinwal/228a448ad6654ae89c4dc2c636591905 to your computer and use it in GitHub Desktop.
var topOffset: CGFloat = 0.0
private let kTopWindowAspectRatio : CGFloat = 3.0/4.0
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// Calculate the top offset and set it if not corectly set
if(topOffset != CGRectGetWidth(pullDownTableView.bounds) * kTopWindowAspectRatio) {
topOffset = CGRectGetWidth(pullDownTableView.bounds) * kTopWindowAspectRatio
// Setup table view insets and offsets
let topInset = CGRectGetHeight(pullDownTableView.bounds)
pullDownTableView.contentInset = UIEdgeInsetsMake(topInset, 0, 0, 0);
pullDownTableView.contentOffset = CGPointMake(0, -topOffset)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment