edgesForExtendedLayout对子vc的view的影响
2015-12-23 10:00
411 查看
将vc的edgesForExtendedLayout设为none后,
如果顶部有导航栏,且显示状态栏。
vc.view的坐标原点从0会变为64,而且高度会相应的减少64。
而且,如果在vc在想用其它vc的view,
在设了此view的frame后,此view的高度竟然也后自动减少64,但其y值不会变。
经检查,是因为后加入的vc的view的默认的autoresizingMask值的原因,
其值是18转为2进制是10010,
也就是UIViewAutoresizingFlexibleWidth和UIViewAutoresizingFlexibleHeight,
而普通的view的autoresizingMask是0。
所以,在根vc的view因为edgesForExtendedLayout设为UIRectEdgeNone后,会将高度减少64,则
子vc的view就因为其autoresizingMask值的原因,高度也跟着减少了64。
所以解决方案就是
方式一、子vc的view用相对定位。
方式二、将子vc的view的autoresizingMask设为UIViewAutoresizingNone。
参考一,取autoResizing 的值:
UIViewAutoresizing autoResizing = testView.autoresizingMask;
if ( autoResizing & UIViewAutoresizingFlexibleWidth){
NSLog(@"选中了UIViewAutoresizingFlexibleWidth");
}
if ( autoResizing & UIViewAutoresizingFlexibleHeight){
NSLog(@"选中了UIViewAutoresizingFlexibleWidth");
}
参考二,UIViewAutoresizing的各项值。
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
如果顶部有导航栏,且显示状态栏。
vc.view的坐标原点从0会变为64,而且高度会相应的减少64。
而且,如果在vc在想用其它vc的view,
在设了此view的frame后,此view的高度竟然也后自动减少64,但其y值不会变。
经检查,是因为后加入的vc的view的默认的autoresizingMask值的原因,
其值是18转为2进制是10010,
也就是UIViewAutoresizingFlexibleWidth和UIViewAutoresizingFlexibleHeight,
而普通的view的autoresizingMask是0。
所以,在根vc的view因为edgesForExtendedLayout设为UIRectEdgeNone后,会将高度减少64,则
子vc的view就因为其autoresizingMask值的原因,高度也跟着减少了64。
所以解决方案就是
方式一、子vc的view用相对定位。
方式二、将子vc的view的autoresizingMask设为UIViewAutoresizingNone。
参考一,取autoResizing 的值:
UIViewAutoresizing autoResizing = testView.autoresizingMask;
if ( autoResizing & UIViewAutoresizingFlexibleWidth){
NSLog(@"选中了UIViewAutoresizingFlexibleWidth");
}
if ( autoResizing & UIViewAutoresizingFlexibleHeight){
NSLog(@"选中了UIViewAutoresizingFlexibleWidth");
}
参考二,UIViewAutoresizing的各项值。
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
相关文章推荐
- [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets
- 关于适配的一些小小心得(iOS7)
- iOS7导航栏遮盖问题的解决
- navigationBar对视图布局的影响,今天终于弄清楚了
- WKWebView隐藏导航栏后顶部出现空白
- 关于UIScrollView上方有空白问题
- automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout和extendedLayoutIncludesOpaqueBars
- iOS UITableview cell 顶部空白区的去除
- 析edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets
- edgesForExtendLayout 属性
- Android中类ListPreference使用介绍
- 【转载】将思维导图上传到博客的好方法
- Java 大作业回忆--day06-- 我们的手机触控板
- php中file_get_contents与curl性能比较分析
- echart 点击事件
- 多线程死锁
- WebService部署到IIS上
- 使用JET自动生成代码
- web在线打印,打印阅览,打印维护,打印设计
- 12.23,搜索标记