edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性见解

iOS7之后的版本,viewController为全屏布局,坐标系起点为屏幕的左上角,这些属性会对坐标系的起点有影响

edgesForExtendedLayout

edgesForExtendedLayout The extended edges to use for the layout. This
property is applied only to view controllers that are embedded in a
container such as UINavigationController. The window’s root view
controller does not react to this property. The default value of this
property is UIRectEdgeAll.

只给viewController的view加个红色背景色

self.view.backgroundColor = [UIColor redColor];


这个属性是指定屏幕延伸的方向,这个属性默认为UIRectEdgeAll,即向屏幕的四周延伸
现在设置这个属性为UIRectEdgeNone,看看结果

self.edgesForExtendedLayout = UIRectEdgeNone;

extendedLayoutIncludesOpaqueBars

A Boolean value indicating whether or not the extended layout includes
opaque bars. The default value of this property is NO. Note Bars are
translucent by default in iOS 7.0

延伸的布局是否包含一个不透明的bar,在iOS7之后bar默认是半透明的
现在给navigationBar设置一个纯色不透明的背景图片

// 生成纯色图片
CGSize imageSize =CGSizeMake([[UIScreen mainScreen] bounds].size.width, 44);
UIGraphicsBeginImageContextWithOptions(imageSize,0, [UIScreen mainScreen].scale);
[[UIColor blueColor] set];
UIRectFill(CGRectMake(0,0, imageSize.width, imageSize.height));
UIImage *pressedColorImg =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// 设置导航栏背景
[self.navigationController.navigationBar setBackgroundImage:pressedColorImg forBarMetrics:UIBarMetricsDefault];

// 测试view
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 10, 200, 100)];
view.backgroundColor = [UIColor blackColor];
[self.view addSubview:view];

现在设置extendedLayoutIncludesOpaqueBars的属性值为YES

self.extendedLayoutIncludesOpaqueBars = YES;

可以发现现在页面的起始坐标变成了屏幕左上角

automaticallyAdjustsScrollViewInsets

A Boolean value that indicates whether the view controller should
automatically adjust its scroll view insets. The default value of this
property is YES, which lets container view controllers know that they
should adjust the scroll view insets of this view controller’s view to
account for screen areas consumed by a status bar, search bar,
navigation bar, toolbar, or tab bar. Set this property to NO if your
view controller implementation manages its own scroll view inset
adjustments.

这个属性决定视图控制器会不会自动的帮我们处理例如ScrollView以及继承于它的控件。这个属性默认为YES,如果我们希望手动的去控制视图的显示,就设置这个属性为NO
未设置的情况下

设置这个属性为NO

self.automaticallyAdjustsScrollViewInsets = NO;


坐标起点变为了屏幕左上角

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值