Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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
Ios7 PopViewControllerInitiated上的UINavigationBar自定义丢失 我的设置_Ios7_Uinavigationcontroller_Uinavigationbar_Customization - Fatal编程技术网

Ios7 PopViewControllerInitiated上的UINavigationBar自定义丢失 我的设置

Ios7 PopViewControllerInitiated上的UINavigationBar自定义丢失 我的设置,ios7,uinavigationcontroller,uinavigationbar,customization,Ios7,Uinavigationcontroller,Uinavigationbar,Customization,在iOS 7中,在一个UINavigationController中,我推出了3个UIViewController,每个UIViewController使用不同的外观自定义UINavigationBar,但方式如下: - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self customizeNavBar]; } - (void) customizeNavBar { [s

在iOS 7中,在一个UINavigationController中,我推出了3个UIViewController,每个UIViewController使用不同的外观自定义UINavigationBar,但方式如下:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self customizeNavBar];
}
- (void) customizeNavBar
{
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    self.navigationController.navigationBar.translucent = YES;

    CALayer *navBar = [CALayer layer];
    [navBar setBackgroundColor:[[UIColor whiteColor] CGColor]];
    [navBar setFrame:CGRectMake(0, -20, 320, 64)];
    [navBar setOpacity:0.4];

    [self.navigationController.navigationBar.layer insertSublayer:navBar atIndex:0];
}
AppDelegate上没有任何自定义项

我的问题
推VC时一切正常,但当弹出时,这是应用的最后一个自定义项—剩下的一个,我没有找到方法再次应用相应的自定义项。

首先,iOS 7导航栏颜色令人头痛,从7.0版更改为7.1版。但这里有一个可能对你有用的解决方案

当你显示一个新的VC时,你必须移除导航栏CALayer,这样当你弹出VC时,导航栏的颜色会正确更新

这种解决方案的唯一问题是,在从透明导航条过渡到非半透明导航条的过程中,您会注意到这种变化

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    self.navigationBar.translucent = NO;
    [self.navColourView.layer removeFromSuperlayer];
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    self.navigationBar.translucent = YES;
    [self.navigationBar.layer insertSublayer:self.navColourView.layer atIndex:1];
}
下面是关于这个话题的讨论