objective-c - 設定NavigationBar為全透明的時候,statusBarStyle無法設定為Light
迷茫
迷茫 2017-05-02 09:32:46
0
1
808

當我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的..
求解各位大神!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回覆(1)
PHPzhong

終於在stackoverflow找到對應的解答,加上下面這句
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

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
will give white status bar text (ie. UIStatusBarStyleLightContent),
and UIBarStyleDefault will give ackleLightContent),
and UIBarStyleDefault will give ack status bar text.

Note that this applies even if you totally change the navigationBar’s

color via its barTintColor.

具體的連結:http://stackoverflow.com/ques...

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板