-
与导航栏相关的四个属性:translucent、edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets
-
导航栏默认样式
- translucent(透明)--Default is NO on iOS 6 and earlier. Always YES if barStyle is set to UIBarStyleBlackTranslucent
- edgesForExtendedLayout--Defaults to UIRectEdgeAll
- automaticallyAdjustsScrollViewInsets--Defaults to YES
- extendedLayoutIncludesOpaqueBars--Defaults to NO
- 默认效果:导航栏透明、rootView的布局从(0, 0)开始
-
iOS7及其之后,translucent默认为YES(true),即导航栏透明,rootView布局从(0, 0)开始,修改edgesForExtendedLayout可改变布局;
-
translucent修改为NO(false),即导航栏不透明,rootView布局从导航栏底部开始,修改edgesForExtendedLayout属性无法修改布局,可通过修改extendedLayoutIncludesOpaqueBars属性为YES从(0, 0)开始布局;
-
automaticallyAdjustsScrollViewInsets 默认值是 YES(true),表示在全屏模式下会自动修改第一个添加到 rootView 的 scrollview 的 contentInset 为(64,0,0,0),用来纠正scrollview在全屏模式下的显示;
-
设置 UINavigationBar 的背景图片可以改变导航栏背景色,如果背景图片包含 alpha 的色值,系统会默认将 translucent 设置为 true,没有包含 alpha 色值会将 translucent 设置为 false。但这是针对没有手动设置 translucent 值的情况,如果我们手动设置了 translucent,那么系统就不会根据背景图片的 alpha 来修改 translucent。