前言
在平时的开发中,打开布局查看器老是遇见 self.view 有的控制器顶在了 navagationbar 上面,有的控制器顶在了 navagationbar 下面;一直很纠结这个问题,最近专门研究一下,并记录下来。

这里不做详细介绍了,如果不愿意详细看下面文章就看我总结吧,很详细的介绍在:https://www.jianshu.com/p/6925ce1b9e34
这里做一个总结:
- 影响到 self.view 是顶入顶部(有 navagationbar)或者底部(有 tabbar)有三个属性可以影响到:
- isTranslucent(所属 UINavigationBar),
- edgesForExtendedLayout(所属 UIViewController),
- extendedLayoutIncludesOpaqueBars(所属 UIViewController)
-
isTranslucent 与 edgesForExtendedLayout 相互影响是否顶入顶部或底部, 举例:
- (isTranslucent 为 true 和 edgesForExtendedLayout 为 all )就 self.view 顶入顶部和底部,
- (isTranslucent 为 false 和 edgesForExtendedLayout 为 all )就 self.view 不顶入顶部和底部,
- (isTranslucent 为 true 和 edgesForExtendedLayout 为.top )就 self.view 顶入顶部和不顶入底部, 其他的属性就自己揣测吧。
-
extendedLayoutIncludesOpaqueBars = true 可忽略 isTranslucent 对导航栏的影响(可以理解为:在其他默认设置情况先设置 extendedLayoutIncludesOpaqueBars = true, self.view 顶入顶部和底部);