浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars
来源:互联网 发布:银行大数据精准营销 编辑:程序博客网 时间:2024/05/17 04:54
iOS 7以后在ViewController里面引进了一系列属性用于管理页面布局。
下面是Apple官方提供的文档解释,看过之后还是觉得太过于抽象,于是用代码来实验吧。
edgesForExtendedLayout
automaticallyAdjustsScrollViewInsets
A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.
extendedLayoutIncludesOpaqueBars
- (void)viewDidLoad { [super viewDidLoad]; self.edgesForExtendedLayout = UIRectEdgeNone;}
将edgesForExtendedLayout设置成UIRectEdgeNone,表明View是不要扩展到整个屏幕的。页面效果如下:
UIRectEdge是个枚举类型,其他的值通过字面意思也是非常容易理解的。
typedef enum : NSUInteger { UIRectEdgeNone = 0, UIRectEdgeTop = 1 << 0, UIRectEdgeLeft = 1 << 1, UIRectEdgeBottom = 1 << 2, UIRectEdgeRight = 1 << 3, UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight } UIRectEdge;
automaticallyAdjustsScrollViewInsets
这个属性用于如果页面是ScrollView或者UITableView,通常我们希望ScrollView或者UITableView内容显示是在UINavigation Bar下面。
通过设置edgesForExtendedLayout = UIRectEdgeNone或者self.navigationController.navigationBar.translucent = NO;可以让view的布局从UINavigation Bar下面开始,不过一个副作用就是当页面滑动的时候,view是没有办法占据全屏的。
automaticallyAdjustsScrollViewInsets就可以很好的完成这个需求。
self.automaticallyAdjustsScrollViewInsets = NO;
这时UITableView会被UINavigation Bar遮挡住。
self.automaticallyAdjustsScrollViewInsets = YES;
这时可以看到UITableView的内容会从UINavigation Bar下面开始,并且这个页面的View还是占据整个屏幕的,所以这一个属性完全搞定!
extendedLayoutIncludesOpaqueBars
如果状态栏是不透明的,那么页面的布局默认是不会包含状态栏的,除非将这个属性设置成为YES。所以如果你的页面扩展到Navigation Bar (edgesForExtendedLayout=UIRectEdgeAll),要是这个属性设置成NO (default), 如果状态栏是不透明的话,页面是不会扩展到状态栏的。
- 浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars
- 浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
- automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout和extendedLayoutIncludesOpaqueBars
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性见解
- iOS7中edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets的区别
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- automaticallyAdjustsScrollViewInsets
- iOS 7中的extendedLayout
- edgesForExtendedLayout&& extendedLayoutIncludesOpaqueBars&&translucent
- 4. Median of Two Sorted Arrays
- MyEclipse调试maven第三方jar包源码
- 端口渗透总结
- WCF使用安全证书验证消息加密
- 如何在互联网环境下生存下去?
- 浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars
- 刨根问底Java多线程系列(1):线程状态
- DEV 中 gridControl1添加checkbox 列
- 敏捷项目开发中的需求分析
- ChemDraw 15.1 Pro怎么绘制彩色结构
- 强悍的命令行 —— 命令行域名的解析
- lingo解题报告内容解释
- vim编辑器
- iOS数据存储方式