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的更多相关文章

  1. edgesForExtendedLayout,automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars的影响

    在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEd ...

  2. 浅析extendedLayout, automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars

    参考文章: http://stackoverflow.com/questions/18798792/explaining-difference-between-automaticallyadjusts ...

  3. iOS系统中导航栏的转场解决方案与最佳实践

    背景 目前,开源社区和业界内已经存在一些 iOS 导航栏转场的解决方案,但对于历史包袱沉重的美团 App 而言,这些解决方案并不完美.有的方案不能满足复杂的页面跳转场景,有的方案迁移成本较大,为此我们 ...

  4. 第14月第17天 automaticallyAdjustsScrollViewInsets contentInsetAdjustmentBehavior

    1. automaticallyAdjustsScrollViewInsets self.edgesForExtendedLayout = UIRectEdgeNone; if ([self resp ...

  5. iOS edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解

    edgesForExtendedLayout: 在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局,就离不开这个属性 edgesForExtendedLa ...

  6. edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解 )——转载

    edgesForExtendedLayout: 在ios7适配中,布局问题是一个很头痛也很重要的问题,因为在ios7中viewController使用了全屏布局的方式,也就是说导航栏和状态栏都是不占实 ...

  7. 与导航栏下控件的frame相关的edgesForExtendedLayout、translucent、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets等几个属性的详解

    在引入了导航控制器UINavigationController和分栏控制器UITabBarController之后,我们在设置控件的frame的时候就需要注意避开导航栏UINavigationBar ...

  8. [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets

    在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEd ...

  9. UIViewController 的 edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets属性

    1.有时你命名设置了某控件的y坐标为0,确总是被导航栏遮挡住,如下: UILabel *label = [[UILabel alloc] init];    label.text = @"请 ...

随机推荐

  1. 关于Windows 8使用WMP播放音乐时WUDFHost跑CPU和硬盘的问题解决

    Windows 8使用Windows Media Player播放音乐的时候.事实上有一个这种情况,WMP和某个什么名字看起来非常屌的进程跑CPU非常高,这个跑非常高视你插入的SD卡内的文件数或者移动 ...

  2. 一个python自动化测试的例子

    http://blog.csdn.net/galen2016/article/details/70882483 https://www.cnblogs.com/TankXiao/category/47 ...

  3. Fragment进阶(五)----->监听fragment回退事件

    activity_main.xml <? xml version="1.0" encoding="utf-8"?> <LinearLayout ...

  4. Chrome插件(扩展)

    [干货]Chrome插件(扩展)开发全攻略   写在前面 我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的,所以转载务必保留出处.本文所有涉及到的大部分代码均 ...

  5. Objective-C语言的 if ( self = [super init] )

    我们先假设如今自己创建了个类.我们起名叫MyObject,继承于NSObject. 继承知道吧,就是你这个子类(MyObject)假设什么都不写的话,和父类(NSObject)就是一模一样的. OC里 ...

  6. 鸟哥的Linux私房菜-----9、vi文本处理器

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGVrZXdhbmd6aQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  7. 基于AR谱特征的声目标识别

    本文第一部分先解释AR谱,但并不会给出太多的细节,第二部分介绍几种常见的语音中的特征.有些在之前的博文中已经用过.诸如过零率. 第三部分给出实际操作的过程及识别的效果.本文的目标是通过对DSP採集的声 ...

  8. [办公自动化]凭证纸打印 IE 默认设置

    财务人员需要打印凭证纸,系统windows7,打印机HP P1106 在自定义纸张类型中设置凭证纸. 属性,打印首选项,“纸张和质量”选卡处,单击自定义(需要管理员权限) 输入“PZ” 宽148 高2 ...

  9. easyUI的下拉框combobox与树tree联动

    参与联动的有 2 个combobox 和 1 个tree: <input id="combobox1" class="easyui-combobox" n ...

  10. 用py文件调用操作系统的命名,粘包问题

    帅爆太阳的男人 1,执行代码 在py代码中去调用操作系统的命令 新的模块:subprocess, import subprocess r = subprocess().Popen( "dir ...