IOS7 适配应用高度

来源:互联网 发布:淘宝服务器时间同步 编辑:程序博客网 时间:2024/05/17 10:25

方法1:

在plist中View controller-based status bar appearance NO 添加个这个字段

在appDelegate.m中添加

if(IOS7){       [application setStatusBarStyle:UIStatusBarStyleLightContent];       self.window.clipsToBounds = YES;       self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height - 20);}

方法2:

在自定义的navigationController或者主navigation 中使用下面的代码适配ios6和7的导航条图片

if (IOS7) {        UIImage * image = [[UIImage imageNamed:@"navg_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 2, 64, 2) resizingMode:UIImageResizingModeTile];        [[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];    }else{        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"navg_bg"] forBarMetrics:UIBarMetricsDefault];}

如果只有部分view出现错位,则在该位中单独调整位置。

if (IOS7) {        self.view.bounds = CGRectMake(0, -64, 320, 568);    }





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

修复这个问题的快速方法就是在方法- (void)viewDidLoad中添加如下一行代码:
self.edgesForExtendedLayout = UIRectEdgeNone;

0 0
原创粉丝点击