我正在更新我的应用程序以将导航栏的颜色从白色更改为蓝色.因此,我想将状态栏的颜色从黑色更改为白色.我已经尝试了Apple文档中的所有内容,这有助于我在Storyboard中更改所有View控制器的状态栏样式.
但是,我推到的任何笔尖都不在我的故事板中,使用presentViewController会自动更改UIStatusBarStyle - 这是我的推送代码:
NSString *url = @"https://twitter.com/Example"; NSString *title = @"Example"; SocialWebViewController *addController = [[[SocialWebViewController alloc] initWithURL:url title:title] initWithNibName:@"SocialWebView_iPhone" bundle:nil]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; [self presentViewController:navigationController animated:YES completion:nil];
我已经在我的AppDelegate中放置了UIStatusBar首选样式,这对我的StoryBoard中的ViewControllers起作用,但是只有:
- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
是的,我已经尝试过了:
(1) [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
(2) [self setNeedsStatusBarAppearanceUpdate];
(3)在plist中将UIViewControllerBasedStatusBarAppearance设置为YES
没有这个适用于那些不在我的StoryBoard中的笔尖.
确定所以我想出你所说的是什么 - 设置查看基于控制器的状态栏外观"否"不是为我工作因为我的状态栏在应用程序启动期间一直隐藏,因为我在设置时一直隐藏它UIViewControllerBasedStatusBarAppearance为"NO"...我该如何解决这个问题?
在您的*-Info.plist
文件中设置键:
UIStatusBarStyle = UIStatusBarStyleLightContent UIViewControllerBasedStatusBarAppearance = NO UIStatusBarHidden = YES
并在您AppDelegate
添加此行到方法application:didFinishLaunchingWithOptions
:
[[UIApplication sharedApplication] setStatusBarHidden:NO];