美文网首页
scrollView加载子视图偏移问题(iOS)

scrollView加载子视图偏移问题(iOS)

作者: 桐丘 | 来源:发表于2016-01-11 16:47 被阅读1032次

问题:
如下图

Main.storyboard
添加scrollView到ChangeViewController对象changeVC的根视图,再添加若干视图到scrollView上,若此时changeVC .navigationController.navigationBar.translucent = YESscrollView的子视图的frame.origin.y会向下偏移,偏移量为changeVC .navigationController.navigationBar.bounds.size.height + [UIApplication sharedApplication].statusBarFrame.size.height即导航条的高度与状态栏高度之和。若关闭了导航条毛玻璃效果,则不会有偏移。

解决方法:

if (changeVC.navigationController.navigationBar.translucent) {
      changeVC.automaticallyAdjustsScrollViewInsets = NO;
}

相关文章

网友评论

      本文标题:scrollView加载子视图偏移问题(iOS)

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