Skip to content

Instantly share code, notes, and snippets.

@danielctull
Created February 6, 2014 11:17
Show Gist options
  • Save danielctull/8842328 to your computer and use it in GitHub Desktop.
Save danielctull/8842328 to your computer and use it in GitHub Desktop.
Inset scrollviews
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self modifyEdgeInsetsOfScrollView:self.tableView];
[self modifyEdgeInsetsOfScrollView:self.webView.scrollView];
}
- (void)modifyEdgeInsetsOfScrollView:(UIScrollView *)scrollview {
scrollview.contentInset = [self modifiedEdgeInsets:scrollview.contentInset];
scrollview.scrollIndicatorInsets = [self modifiedEdgeInsets:scrollview.scrollIndicatorInsets];
}
- (UIEdgeInsets)modifiedEdgeInsets:(UIEdgeInsets)edgeInsets {
UIEdgeInsets modifiedInsets = edgeInsets;
modifiedInsets.top = self.topLayoutGuide.length;
modifiedInsets.bottom = self.bottomLayoutGuide.length;
return modifiedInsets;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment