美文网首页
UITableView & UIScrollView 适

UITableView & UIScrollView 适

作者: F森 | 来源:发表于2016-07-29 16:34 被阅读136次

前提: navigationBar 和 tabBar 放开毛玻璃效果时,为了避免让navigationBar 和 tabBar 遮挡 tableView或scrollView上的内容,我们需要对tableView或scrollView做一些适配工作,让tableView和scrollView有更好的用户体验。

备注:只有当tableView或scrollView的frame “等于” viewController.view.frame 时需要做适配工作,如果您已给tableView或scrollView的frame设置“避开”了navigationBar和tabBar,那么请忽略本篇文章。

以scrollView为例:

步骤一:
(1)只适配UINavigationBar
scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
(2)只适配UITabBar
scrollView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
(3) 适配UINavigationBar + UITabBar
scrollView.contentInset = UIEdgeInsetsMake(64, 0, 64, 0);

步骤二:
说明:跟 scrollView.showsVerticalScrollIndicator 相关
修改:scrollView.scrollIndicatorInsets = scrollView.contentInset;

相关文章

网友评论

      本文标题:UITableView & UIScrollView 适

      本文链接:https://www.haomeiwen.com/subject/wsuzjttx.html