iOS开发导航条覆盖View的问题

来源:互联网 发布:淘宝pc端链接转手机端 编辑:程序博客网 时间:2024/06/05 03:12

在iOS开发中我们会遇到有时候导航条覆盖了view的问题,接下来介绍两种解决方法:
1、原因是导航条是透明的所以control的起点坐标会在屏幕左上角开始,而不是导航条的左下角,解决方法设置导航条为不透明的。
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.translucent=NO;
}
2、在iOS7以后加入了edgesForExtendedLayout属性默认值是UIRectEdgeAll,这时候起点(0,0)坐标是从导航条左上角。所以需要设置edgesForExtendedLayout属性。
- (void)viewDidLoad {
[super viewDidLoad];
if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)) {
self.edgesForExtendedLayout = UIRectEdgeNone;
//默认为UIRectEdgeAll,当你的容器是UINavigationController时,默认的布局将从navigation bar的顶部开始。
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
}
}

0 0
原创粉丝点击