Skip to content

Instantly share code, notes, and snippets.

@ellneal
Created April 30, 2012 11:04
Show Gist options
  • Save ellneal/2557391 to your computer and use it in GitHub Desktop.
Save ellneal/2557391 to your computer and use it in GitHub Desktop.
Static View at bottom of UIScrollView - place in layoutSubviews
UIView *staticFooterView = <#static view#>;
CGRect visibleBounds = self.bounds;
CGRect staticFooterFrame = staticFooterView.frame;
CGRect contentRect = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height);
if (CGRectGetMaxY(visibleBounds) > CGRectGetMaxY(contentRect)) {
staticFooterFrame = CGRectMake(visibleBounds.origin.x, CGRectGetMaxY(contentRect) - staticFooterFrame.size.height, staticFooterFrame.size.width, staticFooterFrame.size.height);
}
else {
staticFooterFrame = CGRectMake(visibleBounds.origin.x, CGRectGetMaxY(visibleBounds) - staticFooterFrame.size.height, staticFooterFrame.size.width, staticFooterFrame.size.height);
}
staticFooterView.frame = staticFooterFrame;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment