Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 状态栏颜色与导航栏不匹配_Ios_Statusbar - Fatal编程技术网

Ios 状态栏颜色与导航栏不匹配

Ios 状态栏颜色与导航栏不匹配,ios,statusbar,Ios,Statusbar,我现在有一个视图控制器。我希望状态栏颜色与导航栏颜色匹配 我已将UIViewControllerBasedStatusBarAppearance设置为“是”,因为我不希望在整个应用程序中进行此更改 我正在设置self.navigationController.navigationBar.barTintColor,但这只是更改导航栏的颜色。状态栏保持较浅的颜色 我已经尝试过setNeedsStatusBarAppearanceUpdate和preferredStatusBarStyle的各种组合,

我现在有一个视图控制器。我希望状态栏颜色与导航栏颜色匹配

我已将UIViewControllerBasedStatusBarAppearance设置为“是”,因为我不希望在整个应用程序中进行此更改

我正在设置self.navigationController.navigationBar.barTintColor,但这只是更改导航栏的颜色。状态栏保持较浅的颜色

我已经尝试过setNeedsStatusBarAppearanceUpdate和preferredStatusBarStyle的各种组合,但都没有效果

视图控制器按如下方式启动:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

[self presentViewController:navigationController animated:YES completion:nil];

我的步骤如下,检查哪里出了问题:

  • 创建2个视图控制器,如下所示,您可以将vc1嵌入导航控制器中:
  • 在vc1中,拖动按钮的动作:
  • 代码如下:

    - (IBAction)clickAction:(UIButton *)sender {
    
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        ViewController2 *searchController = [sb instantiateViewControllerWithIdentifier:@"ViewController2"];
    
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
    
        navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
    
        [self presentViewController:navigationController animated:YES completion:nil];
    }
    
  • 然后在vc2中设置标题:

  • 如何创建导航栏?视图控制器嵌入在导航控制器中。问题中添加了代码。你的意思是:是的,这就是我希望它看起来的样子。好的,我确信问题是由你的错误步骤造成的。我将给出我的步骤。我发现了问题。有人将此添加到viewDidLoad中的一个方法中:self.navigationController.navigationBar.clipsToBounds=true;