Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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 - Fatal编程技术网

Ios 第一次按下时,黑色半透明导航栏闪烁不透明

Ios 第一次按下时,黑色半透明导航栏闪烁不透明,ios,Ios,我有一个导航控制器,我在其中设置navigationBar.barStyle=UIBarStyleBlack和navigationBar.translucent=YES(根据苹果的建议,因为他们不推荐UIBarStyleBlackTranslucent)。在模拟指标中的两个nib文件(这不是使用故事板)中,我将顶部栏设置为黑色导航栏 SettingsViewController *controller = [[SettingsViewController alloc] initWithNibNa

我有一个导航控制器,我在其中设置navigationBar.barStyle=UIBarStyleBlack和navigationBar.translucent=YES(根据苹果的建议,因为他们不推荐UIBarStyleBlackTranslucent)。在模拟指标中的两个nib文件(这不是使用故事板)中,我将顶部栏设置为黑色导航栏

SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];

controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(closeSettings)];

controller.navigationController.navigationBar.barStyle = UIBarStyleBlack;
controller.navigationController.navigationBar.translucent = YES;

[self presentViewController:navController animated:YES completion:nil];
当我展示导航控制器时,它会正确地打开黑色半透明条,但当我随后推到下一个表视图时,导航条会迅速淡入不透明状态,然后在大约200毫秒的过程中返回半透明状态。它几乎是闪烁的不透明,然后又变成半透明

然后,当我按下下一个表格视图或返回(按下导航栏左上角的按钮或弹出视图)时,它不会闪烁。在整个导航控制器关闭之前,它始终保持半透明

我想这可能是因为笔尖是用不透明条设置的,但我已经尝试了每种类型的选项(半透明、常规蓝色、无条),它仍然这样做

此外,它可以在我的应用程序中的两个完全独立的导航控制器上实现这一点。对不起,如果我做了一些明显的错误,但我已经尝试了这么多的选择组合,只是在茫然


谢谢

我认为你根本不应该使用BarStyle,而应该:

[controller.navigationController.navigationBar setTintColor:[UIColor blackColor]];
[controller.navigationController.navigationBar setTranslucent:YES];
我还将尝试设置样式更改的动画,以使显示的视图控制器ViewDidDisplay方法中的样式更改更平滑(请考虑在代码中以黑色不透明条开始):

然后在设置视图控制器代码中输入:

- (void) viewDidAppear:(BOOL)animated {
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:duration];

    [controller.navigationController.navigationBar setTintColor:[UIColor blackColor]];
    [controller.navigationController.navigationBar setTranslucent:YES];

    [UIView commitAnimations];
}

为您的
UIViewController
实例属性
edgesForExtendedLayout
设置适当的值,并将
backgroundColor
设置为
navigationController
,例如:

self.edgesForExtendedLayout = UIRectEdgeBottom;
self.navigationController.view.backgroundColor = [UIColor whiteColor];
希望这能帮助你

SWIFT 5版本

    self.edgesForExtendedLayout = UIRectEdge.bottom
    self.view.backgroundColor = .white
    self.edgesForExtendedLayout = UIRectEdge.bottom
    self.view.backgroundColor = .white