你的位置:首页 > 软件开发 > 操作系统 > [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

发布时间:2016-02-20 12:00:18
在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEdge的属性,指定边缘要延伸的方向,它的默认值很自然地是UIRectEdgeAl ...

 

IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局

就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEdge的属性,

指定边缘要延伸的方向,它的默认值很自然地是UIRectEdgeAll,四周边缘均延伸,就是说,

如果即使视图中上有navigationBar,下有tabBar,那么视图仍会延伸覆盖到四周的区域。

因为一般为了不让tableView 不延伸到 navigationBar 下面, 属性设置为 UIRectEdgeNone

UIRectEdgeAll -- default

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

UIRectEdgeNone 

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

这时会发现导航栏变灰了,处理如下就OK了

 

 self.navigationController.navigationBar.translucent = NO;

 

那 automaticallyAdjustsScrollViewInsets 呢?

当 automaticallyAdjustsScrollViewInsets 为 NO 时,tableview 是从屏幕的最上边开始,也就是被

导航栏 & 状态栏覆盖

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

 

当 automaticallyAdjustsScrollViewInsets 为 YES 时,也是默认行为,表现就比较正常了,和

edgesForExtendedLayout = UIRectEdgeNone 有啥区别? 不注意可能很难觉察

设计师可能一眼就看穿。。。 automaticallyAdjustsScrollViewInsets 为YES 时,

tableView 上下滑动时,是可以穿过导航栏&状态栏的,在他们下面有淡淡的浅浅红色

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

extendedLayoutIncludesOpaqueBars 

首先看下官方解释,默认 NO, 但是Bar 的默认属性是 透明的。。。也就是说只有在不透明下才有用

但是,测试结果很软肋,基本区别不大。。。但是对于解决一些Bug 是还是起作用的,比如说SearchBar的

跳动问题,详情见:http://www.cnblogs.com/skyming/p/4059128.html, 其他UITableView,UIScrollView 位置的

问题多数和这3属性相关。。

[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets


 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:[IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。