美文网首页
iOS 视图内置问题

iOS 视图内置问题

作者: MonkeysAndTyper | 来源:发表于2016-05-10 11:40 被阅读0次

    automaticallyAdjustsScrollViewInsets 防止视图内置
    当我们采用全屏布局设置了 edgesForExtendedLayout 为 UIRectEdgeAll,而 此时 View Controller 的 self.view 的第一个 Subview 是 UIScrollView 类型或其 子类型(如:UITableView 等)时,automaticallyAdjustsScrollViewInsets
    这个属性就会被用来辅助我们对 UIScrollView 类的视图进行布局。automaticallyAdjustsScrollViewInsets 默认值即为 YES。
    拿 UITableView 来举例,你希望你的 UITableView 的内容从 NavigationBar 底部开始展示(因为不这样的话就会被 NavigationBar 遮住一部分),同时还需要在滑动时,UITableView 的布局又能填满全屏。这时你只需要设置 automaticallyAdjustsScrollViewInsets 为 YES 即可,系统会帮你调整 UITableView 的 contentInset 来实现效果使其中的内容不会被 NavigationBar、TabBar、TooBar 挡住(和手动设置contentInset有区别,手动的不美观,进度条没下移)。你可以同样在 - (void)viewWillLayoutSubviews
    观察 UITableView 的 contentInset 的值。

    相关文章

      网友评论

          本文标题:iOS 视图内置问题

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