Maison  >  Questions et réponses  >  le corps du texte

objective-c - 设置NavigationBar为全透明的时候,statusBarStyle无法设定为Light

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

迷茫迷茫2698 Il y a quelques jours752

répondre à tous(1)je répondrai

  • PHPz

    PHPz2017-05-02 09:34:46

    终于在stackoverflow找到对应的解答,加上下面这句
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    J'ai découvert que si votre ViewController se trouve à l'intérieur d'un
    navigationController, alors le
    navigationBar.barStyle du navigationController détermine le statusBarStyle.

    Définir le barStyle de votre barre de navigation sur UIBarStyleBlackTranslucent
    donnera un texte de barre d'état blanc (c'est-à-dire UIStatusBarStyleLightContent),
    et UIBarStyleDefault donnera un texte de barre d'état noir (c'est-à-dire.
    UIStatusBarStyleDefault).

    Notez que cela s'applique même si vous changez totalement la
    couleur de la barre de navigation via sa barTintColor.

    具体的链接 :http://stackoverflow.com/ques...

    répondre
    0
  • Annulerrépondre