automaticallyAdjustsScrollViewInsets 和edgesForExtendedLayoutse和translucent

来源:互联网 发布:类似prezi的软件 编辑:程序博客网 时间:2024/05/29 07:58

automaticallyAdjustsScrollViewInsets 默认值即为 YES

@property(nonatomic,assign)BOOL automaticallyAdjustsScrollViewInsetsNS_AVAILABLE_IOS(7_0);// Defaults to YES


View Controller 的 self.view 的第一个 Subview 是 UIScrollView 类型或其子类型(如:UITableView 等)时

你希望你的 UITableView 的内容从 NavigationBar 底部开始展示(因为不这样的话就会被 NavigationBar 遮住一部分,同时还需要在滑动时,UITableView 的布局又能填满全屏。这时你只需要设置 automaticallyAdjustsScrollViewInsets 为 YES 即可

通常情况下如果在一个控制器中有且只有一个 ScrollView 或其子类时,滑动范围会向下移动64px,从而实现穿透导航栏的效果,该属性只会影响到有ScrollView或其子类的页面。

self.automaticallyAdjustsScrollViewInsets =YES;


self.automaticallyAdjustsScrollViewInsets =NO;



edgesForExtendedLayout 默认值即为 UIRectEdgeAll

@property(nonatomic,assign)UIRectEdge edgesForExtendedLayoutNS_AVAILABLE_IOS(7_0);// Defaults to UIRectEdgeAll

edgesForExtendedLayout,它是一个类型为UIExtendedEdge的属性,指定边缘要延伸的方向,它的默认值很自然地是UIRectEdgeAll,四周边缘均延伸,就是说,如果即使视图中上有navigationBar,下有tabBar,那么视图仍会延伸覆盖到四周
UIRectEdgeAll


UIRectEdgeNone


当 automaticallyAdjustsScrollViewInsets 为 YES 时,也是默认行为,表现就比较正常了,和edgesForExtendedLayout = UIRectEdgeNone 有啥区别? 不注意可能很难觉察, automaticallyAdjustsScrollViewInsets 为额YES 时,tableView 上下滑动时,是可以穿过导航栏&状态栏的,在他们下面有淡淡的浅浅红色

iOS7之后self.navigationController.navigationBar.translucent = YES;
原点在(0,0)点



当设置NO的时候,原点坐标在(0,64)点


0 0
原创粉丝点击