以下基于UINavigationController 下的 UIViewController 讨论
UIViewController *viewController = [[UIViewController alloc] init];
viewController.view.backgroundColor = [UIColor redColor];
UINavigationController *mainNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
edgesForExtendedLayout
viewController
设置这个属性后,其view会根据设置的方向(上、下、左、右、全部)拓展到屏幕对应的四边。其默认属性是UIRectEdgeAll
,因此会:

上图所示:红色背景扩展到了
navigation bar 和 status bar
后面当设置成
UIRectEdgeNone
时,viewcontroller的view将不会扩展view到屏幕边上
UIViewController *viewController = [[UIViewController alloc] init];
viewController.view.backgroundColor = [UIColor redColor];
viewController.edgesForExtendedLayout = UIRectEdgeNone;
UINavigationController *mainNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
结果:

automaticallyAdjustsScrollViewInsets
这个属性用于UIScrollView及其子类,像UITableView。当设置为YES时你的tableView内容的起始点
可以从navigation bar的底部开始,滑动时内容
又能扩展到整个屏幕
YES(default)

NO

注意观察:两种情况都是tableView扩展到屏幕边上的,但是
内容的起点
是不一样的
extendedLayoutIncludesOpaqueBars
- 这个是作用于
status bar
的,即view
能否扩展到status bar
下面 - 只有在
status bar
是不透明的情况在才起作用,status bar
的默认属性是透明的,即使你设置(edgesForExtendedLayout to UIRectEdgeAll
),也没有效果
所以以下基于status bar 是不透明的情况讨论
1.如果edgesForExtendedLayout = NO (default) ,view
的起始点将是status bar
的底部
2.如果edgesForExtendedLayout = YES,view
的起始点将扩展到status bar
下面
网友评论