Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout
automaticallyAdjustsScrollViewInsets:在导航栏透明时用到
In your viewDidLoad method, add if([self respondsToSelector:@selector(edgesForExtendedLayout)]) self.edgesForExtendedLayout = UIRectEdgeNone; which will force your view to start below the status bar
Starting in iOS7, the view controllers use full-screen layout by default. At the same time, you have more control over how it lays out its views, and that's done with those properties:
edgesForExtendedLayout
Basically, with this property you set which sides of your view can be extended to cover the whole screen. Imagine that you push a UIViewController
into a UINavigationController
. When the view of that view controller is laid out, it will start where the navigation bar ends, but this property will set which sides of the view (top, left, bottom, right) can be extended to fill the whole screen.
Let see it with an example:
Here you are not setting the value of edgesForExtendedLayout
, therefore the default value is taken (UIRectEdgeAll
), so the view extends its layout to fill the whole screen.
This is the result:
As you can see, the red background extends behind the navigation bar and the status bar.
Now, you are going to set that value to UIRectEdgeNone
, so you are telling the view controller to not extend the view to cover the screen:
And the result:
automaticallyAdjustsScrollViewInsets
This property is used when your view is a UIScrollView
or similar, like a UITableView
. You want your table to start where the navigation bar ends, because you wont see the whole content if not, but at the same time you want your table to cover the whole screen when scrolling. In that case, setting edgesForExtendedLayout
to None won't work because your table will start scrolling where the navigation bar ends and it wont go behind it.
Here is where this property comes in handy, if you let the view controller automatically adjust the insets (setting this property to YES, also the default value) it will add insets to the top of the table, so the table will start where the navigation bar ends, but the scroll will cover the whole screen.
This is when is set to NO:
And YES (by default):
In both cases, the table scrolls behind the navigation bar, but in the second case (YES), it will start from below the navigation bar.
extendedLayoutIncludesOpaqueBars
This value is just an addition to the previous ones. By default, this parameter is set to NO. If the status bar is opaque, the views won't be extended to include the status bar, even if you extend your view to cover it (edgesForExtendedLayout
to UIRectEdgeAll
).
If you set the value to YES, this will allow the view to go underneath the status bar again.
If something is not clear, write a comment and I'll answer it.
How does iOS know what UIScrollView to use?
iOS grabs the first subview in your ViewController's view, the one at index 0, and if it's a subclass of UIScrollView
then applies the explained properties to it.
Of course, this means that UITableViewController
works by default (since the UITableView
is the first view).
https://stackoverflow.com/questions/18798792/explaining-difference-between-automaticallyadjustsscrollviewinsets-extendedlayo
Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout的更多相关文章
- edgesForExtendedLayout,automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars的影响
在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEd ...
- 浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars
参考文章: http://stackoverflow.com/questions/18798792/explaining-difference-between-automaticallyadjusts ...
- iOS系统中导航栏的转场解决方案与最佳实践
背景 目前,开源社区和业界内已经存在一些 iOS 导航栏转场的解决方案,但对于历史包袱沉重的美团 App 而言,这些解决方案并不完美.有的方案不能满足复杂的页面跳转场景,有的方案迁移成本较大,为此我们 ...
- 第14月第17天 automaticallyAdjustsScrollViewInsets contentInsetAdjustmentBehavior
1. automaticallyAdjustsScrollViewInsets self.edgesForExtendedLayout = UIRectEdgeNone; if ([self resp ...
- iOS edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
edgesForExtendedLayout: 在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局,就离不开这个属性 edgesForExtendedLa ...
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解 )——转载
edgesForExtendedLayout: 在ios7适配中,布局问题是一个很头痛也很重要的问题,因为在ios7中viewController使用了全屏布局的方式,也就是说导航栏和状态栏都是不占实 ...
- 与导航栏下控件的frame相关的edgesForExtendedLayout、translucent、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets等几个属性的详解
在引入了导航控制器UINavigationController和分栏控制器UITabBarController之后,我们在设置控件的frame的时候就需要注意避开导航栏UINavigationBar ...
- [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets
在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEd ...
- UIViewController 的 edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets属性
1.有时你命名设置了某控件的y坐标为0,确总是被导航栏遮挡住,如下: UILabel *label = [[UILabel alloc] init]; label.text = @"请 ...
随机推荐
- 解决fragmentTransaction.replace不能全屏
今天遇到个问题,使用fragmentTransaction.replace替换后的内容不能全屏.. FragmentManager fragmentManager = getSupportFragme ...
- swift编程语言基础教程 中文版
swift编程语言基础教程 中文版 http://download.csdn.net/detail/u014036026/7845491
- java 代理模式具体解释
java 动态代理(JDK和cglib) 设计模式这东东每次看到就明确可过段时间又不能非常流利的说出来.今天就用具体的比喻和实例来加深自己的理解(小弟水平不高有不正确的地方希望大家能指出来). (1) ...
- 2013级C++第12周(春)项目——成员的訪问属性、多重继承
课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759,内有完整教学方案及资源链接 第一部分 程序阅读 1.阅读程序.分析类中成员 ...
- python generator iterator和iterable object
1 iterable object list.dict.set.tuple.file(在每行上iterate)等都是iterable object,但是它们不是iterator.但是它们可以转换成it ...
- YTU 2623: B 抽象类-形状
2623: B 抽象类-形状 时间限制: 1 Sec 内存限制: 128 MB 提交: 235 解决: 143 题目描述 定义一个抽象类Shape, 类中有两个纯虚函数. 具体类正方形类Shape ...
- OC学习篇之---类的初始化方法和点语法的使用
昨天介绍了OC中类的定义和使用:http://blog.csdn.net/jiangwei0910410003/article/details/41657603,今天我们来继续学习类的初始化方法和点语 ...
- javaSE基础(一)
说明: 1)本系列专综合java SE 之基础概念!因为个人觉得,许多知识点的不理解来自于对各种名称与概念的定义的不理解. 2)其中的定义参考来自于Stuart Reges 和 Marty Stepp ...
- BaezaYates 交集python和golang代码
def bsearch(find, arr, low, high): while low <= high: mid = (low + high) >> 1 if arr[mid] = ...
- POJ2352 star
传送门 这道题有个非常好听的名字,求二维偏序! 听起来似乎很高端,但就是让求满足对于每个i,xi < xj && yi < yj的个数. 这道题特别良心,给的顺序都是y递增 ...