IOS7 edgesForExtendedLayout

来源:互联网 发布:ip变换软件 编辑:程序博客网 时间:2024/05/01 06:48

在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController setEdgesForExtendedLayout:],它的默认值为UIRectEdgeAll。当你的容器是navigation controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。有时会加上顶部tool bar的高度 20, 20+44 = 64

解决办法

- (void)viewDidLoad  

{  

[super viewDidLoad];  

// Do any additional setup after loading the view.  

if (OSVersionIsAtLeastiOS7()) {  

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])  

{  

self.edgesForExtendedLayout = UIRectEdgeNone;  

}  

}  

}  

0 0
原创粉丝点击