我有以下代码来更改状态栏的颜色,它运行正常。
statusBarTintView = [[UIView alloc] initWithFrame:[[UIApplication sharedApplication] statusBarFrame]];
statusBarTintView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
statusBarTintView.backgroundColor = [[Color sharedInstance] navigationBarColor];
[self.window addSubview:statusBarTintView];
[statusBarTintView release];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
但它需要花费很多时间才能改变(仅限第一次)。 我究竟做错了什么? 任何人都可以帮助我吗?
答案 0 :(得分:0)
UIViewControllerBasedStatusBarAppearance
设置为YES
。viewDidLoad
执行[self setNeedsStatusBarAppearanceUpdate]
; 添加以下方法:
- (UIStatusBarStyle) preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
请参阅此答案以了解更多详情。
How to change Status Bar text color in iOS 7
Change status bar text color to light in iOS 9 with Objective C