关于IOS7显示坐标问题

当XCODE到5以后,系统到ios7以后,UIViewController 的显示是占满全屏的,如果你以CGRectMake(0,0,50,50);这样的方式来添加一个空间那样的话,该控件会在信号栏上显示,(这样的控件放到ios7之前显示正常)如何解决这样的问题。如下

1:当该UIViewController没有在UINavigationController中的情况下需要来判断系统版本,如果是7以及以上的系统,Y起点在20像素后

判断语句#define IOS_VERSION_7_OR_ABOVE (([[[UIDevice currentDevice] systemVersion] floatValue] >=7.0)? (YES):(NO))

    if (IOS_VERSION_7_OR_ABOVE) {

        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];

   }else{

        UIView *view = [[UIView alloc] initWithFrame:self.view.frame];

    }

2:当该UIViewController在UINavigationController中,需要从写系统中的界面布局格式,让布局格式在导航栏下开始,在viewDidLoad中添加下面一句

if ([[[UIDevicecurrentDevicesystemVersion]doubleValue]>=7.0) {

        // 为了让视图从导航条下面开始进行

        self.edgesForExtendedLayout =UIRectEdgeNone;

}



注意:

 iOS7以上系统,self.navigationController.navigationBar.translucent默认为YES,self.view.frame.origin.y从0开始(屏幕最上部)。
     此时若是添加代码self.edgesForExtendedLayout = UIRectEdgeNone(iOS7.0以后方法);self.view.frame.origin.y会下移64像素至navBar下方开始。但是此时当push到一个新的controller之前给当前屏幕截图的时候[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];,由于navBar是透明的,会出现64像素的黑色区域。
     
     此时只需要把self.navigationController.navigationBar.translucent=NO即可,不需要加代码self.edgesForExtendedLayout;
     
     
     iOS7之后也增加了一个self.tabBarController.tabBar.translucent的属性,默认为YES。当应用同时使用navBar和TabBar的时候。设置self.tabBarController.tabBar.translucent=NO并且self.navigationController.navigationBar.translucent=NO时候,得到self.view.frame--->{{0, 64}, {320, 455}}。视图的高度也改变为navBar和tabBar之间的455像素。当self.navigationController.navigationBar.translucent=YES并且self.tabBarController.tabBar.translucent=NO的时候self.view.frame--->{{0, 0}, {320, 519}};其都为YES的时候self.view.frame--->{{0, 0}, {320, 568}};
     
     
     注意:设置self.edgesForExtendedLayout = UIRectEdgeNone;的时候会使得navBar和tabBar都不占空间。self.view.frame--->{{0, 64}, {320, 455}}。此时iOS7默认navBar和tabBar都是透明的。截图的时候需要注意。
     
     iOS6以下系统,默认navBar和tabBar都不占空间。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值