Question

I have returned in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];

    RootViewController *rvc = [[[RootViewController alloc] init] autorelease];
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:rvc] autorelease];

    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];
    return YES;

}

View controller-based status bar appearance  is  YES in plist file

when i am pushing view controllers status bar is looking great. As showing in following image.

enter image description here

but when i am presenting modelviewcontroller it look as following.

enter image description here

I have written following code in viewDidLoad method of viewcontroller which I am presenting

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
    // iOS 7
    navBar.frame = CGRectMake(navBar.frame.origin.x, 20, navBar.frame.size.width, 44);
}

I want to display black status bar when presentingmodelview. But it is not displaying. I tried with

View controller-based status bar appearance is NO also in plist file but it is not working.

My code is working great in all ios version below 7.0 but not in ios 7.0 and above.

Any solution for this ? Let me know if any one not getting my question.

Était-ce utile?

La solution

Good solution found in this question .

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);

    self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}
return YES;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top