IOS7 状态栏和 Navigation Bar重叠的问题解决

 

 

一 Status bar重叠问题:

 

方法一:隐藏Status bar   在plist里面增加2个变量  Status bar is initially hidden  -> YES   View controller-based status bar appearance -> NO

方法二:改为和IOS6 一样的显示方式  

  1. Set UIViewControllerBasedStatusBarAppearance to NO in info.plist (To opt out of having view controllers adjust the status bar style so that we can set the status bar style by using the UIApplicationstatusBarStyle method.)

  2. In AppDelegate's application:didFinishLaunchingWithOptions, call

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        [application setStatusBarStyle:UIStatusBarStyleLightContent];
        self.window.clipsToBounds =YES;
        self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
    
        //Added on 19th Sep 2013
        self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
    }

    方法三:

 

Set UIViewControllerBasedStatusBarAppearance to NO in info.plist

Pase this code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
            [application setStatusBarStyle:UIStatusBarStyleLightContent];
            self.window.clipsToBounds =YES;
            self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height);

            //Added on 19th Sep 2013
            NSLog(@"%f",self.window.frame.size.height);
            self.window.bounds = CGRectMake(0,0, self.window.frame.size.width, self.window.frame.size.height);
        }

It may push down all your views by 20 pixels.To over come that use following code in -(void)viewDidAppear:(BOOL)animated method

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect frame=self.view.frame;
        if (frame.size.height==[[NSUserDefaults standardUserDefaults] floatForKey:@"windowHeight"])
        {
            frame.size.height-=20;
        }
        self.view.frame=frame;
    }

You have to set windowHeight Userdefaults value after window allocation in didFinishLauncing Method like

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[[NSUserDefaults standardUserDefaults] setFloat:self.window.frame.size.height forKey:@"windowHeight"];
二  Navigation Bar重叠的问题:

在页面刚生成的时候 initWithNibName 函数 或者其他函数中加一句话:

        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
            self.edgesForExtendedLayout = UIRectEdgeNone;
        }
显示方式就和IOS6 一致了。



如果有什么问题,请留言。

转载于:https://www.cnblogs.com/lingzhao/p/3340768.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值