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 UITableViewis 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 = @"请 ...
随机推荐
- Alluxio增强Spark和MapReduce存储能力
Alluxio的前身为Tachyon.Alluxio是一个基于内存的分布式文件系统:Alluxio以内存为中心设计,他处在诸如Amazon S3. Apache HDFS 或 OpenStack Sw ...
- 使用requireJS的shim參数,完毕jquery插件的载入
没有requireJS框架之前,假设我们想使用jquery框架,会在HTML页面中通过<script>标签载入.这个时候jquery框架生成全局变量$和jQuery等全局变量.假设项目中引 ...
- OpenFileDiag 使用
MSDN模版 Stream myStream =null; OpenFileDialog openFileDialog1 =newOpenFileDialog(); openFileDialog1.I ...
- go10---struct
package main import ( "fmt" ) type test struct{} //空的结构体 type person struct { name string ...
- YTU 2543: 数字整除
2543: 数字整除 时间限制: 1 Sec 内存限制: 128 MB 提交: 33 解决: 8 题目描述 定理:把一个至少两位的正整数的个位数字去掉,再从余下的数中减去个位数的5倍.当且仅当差是 ...
- POJ 3100:Root of the Problem
Root of the Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12060 Accepted: 6 ...
- EJS基本使用
基本使用 Render 渲染字符串 Compile编译字符串到模板函数(需调用才能生成html内容) <!DOCTYPE html> <html lang="en" ...
- hdu 5074 Hatsune Miku DP题目
题目传送门http://acm.hdu.edu.cn/showproblem.php?pid=5074 $dp[i][j] =$ 表示数列前$i$个数以$j$结尾的最大分数 $dp[i][j] = - ...
- lodop
一.控件参数 Lodop有如下控件参数,以页面object对象元素的参数形式使用: Caption名称:设置控件的显示标题格式: < pa ram name="Caption" ...
- expandableListview的默认箭头箭头怎样移到右边
1 . ExpandableListView布局:<ExpandableListView android:id="@+id/bbs_category_expandable_lis ...