當我push到將當前視圖控制器的navigationBar設定為全透明時,
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//设定字体颜色
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//设定背景图片为空
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//半透明
//self.navigationController.navigationBar.translucent = YES;
//
//self.edgesForExtendedLayout = UIRectEdgeNone;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
然而頂端的狀態欄是漆黑一片。
我的上一層VC也使用了preferredStatusBarStyle,但是顯示沒有問題,不同在於上一級VC隱藏了NavigationBar,而push到當前VC的時候是顯示NavigationBar的..
求解各位大神!
PHPz2017-05-02 09:34:46
終於在stackoverflow找到對應的解答,加上下面這句
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
具體的連結:http://stackoverflow.com/ques...I discovered that if your ViewController is inside a
navigationController then the navigationController’s
navigationBar.barStyle determines the statusBarStyle.Setting your navigationBar’s barStyle to UIBarStyleBlackTranslucent
Note that this applies even if you totally change the navigationBar’s
will give white status bar text (ie. UIStatusBarStyleLightContent),
and UIBarStyleDefault will give ackleLightContent),
and UIBarStyleDefault will give ack status bar text.color via its barTintColor.