Created
April 30, 2012 11:06
-
-
Save ellneal/2557400 to your computer and use it in GitHub Desktop.
Static View at top of UIScrollView - place in layoutSubviews
This file contains 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
UIView *staticHeaderView = <#static view#>; | |
CGRect visibleBounds = self.bounds; | |
CGRect staticHeaderFrame = staticHeaderView.frame; | |
CGRect contentRect = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height); | |
if (CGRectGetMinY(visibleBounds) < CGRectGetMinY(contentRect)) { | |
staticHeaderFrame = CGRectMake(visibleBounds.origin.x, CGRectGetMinY(contentRect), staticHeaderFrame.size.width, staticHeaderFrame.size.height); | |
} | |
else { | |
staticHeaderFrame = CGRectMake(visibleBounds.origin.x, CGRectGetMinY(visibleBounds), staticHeaderFrame.size.width, staticHeaderFrame.size.height); | |
} | |
staticHeaderView.frame = headerFrame; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment