iOS 7 status bar back to iOS 6 default style in iPhone app?

前端 未结 25 855
终归单人心
终归单人心 2020-11-22 05:48

In iOS 7 the UIStatusBar has been designed in a way that it merges with the view like this:

\"GUI

相关标签:
25条回答
  • 2020-11-22 06:46

    I have achieved status bar like iOS 6 in iOS 7.

    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"];
    
    0 讨论(0)
提交回复
热议问题