Skip to content

Instantly share code, notes, and snippets.

@hudinwal
Last active August 15, 2016 16:11
Show Gist options
  • Save hudinwal/35b5afd6505fe9819882e0685d8b5298 to your computer and use it in GitHub Desktop.
Save hudinwal/35b5afd6505fe9819882e0685d8b5298 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)
// Align the moveable image view center
moveableImageView.center = view.center
moveableImageView.center.y = topOffset/2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment