Iphone iOS 7 UINavigationbar设置半透明:无崩溃应用程序

Iphone iOS 7 UINavigationbar设置半透明:无崩溃应用程序,iphone,ios,objective-c,ios7,uinavigationbar,Iphone,Ios,Objective C,Ios7,Uinavigationbar,我有一个UINavigationBar,它在app delegate类中设置了一个背景图像,因此您可以想象为什么我不希望导航栏是半透明的。我相信这是罪魁祸首: 不管怎样,当我把这行代码: [[UINavigationBar appearance] setTranslucent:NO]; 在我的AppDelegate中,我遇到以下错误: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reas

我有一个UINavigationBar,它在app delegate类中设置了一个背景图像,因此您可以想象为什么我不希望导航栏是半透明的。我相信这是罪魁祸首:

不管怎样,当我把这行代码:

[[UINavigationBar appearance] setTranslucent:NO];
在我的AppDelegate中,我遇到以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, B for appearance setter, _installAppearanceSwizzlesForSetter:'
即使我试图在每个类中单独使每个UINavigationbar都不透明,我仍然在图像中有那个愚蠢的白色条!但是没有抛出任何错误,这让我怀疑代码是否不起作用,或者透明度是否不是我的问题

谢谢

编辑:

以下是我在AppDelegate中用于为导航栏创建自定义背景的代码:

[[UINavigationBar appearance] setTitleTextAttributes: @{
                                                        UITextAttributeTextColor: [UIColor whiteColor],
                                                        UITextAttributeTextShadowColor: [UIColor blackColor],
                                                        UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
                                                        UITextAttributeFont: [UIFont fontWithName:@"Code-Bold" size:23.0f]
                                                        }];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];

UIImage *navBarImage = [[UIImage imageNamed:@"menubar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 15, 5, 15)];

[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];

即使我将UIViewController的背景设置为黑色,白色条仍然存在。。我现在高度怀疑透明度是我的问题

如果使用Interface Builder,您可以从此禁用半透明

Xib文件->属性检查器->模拟度量并将顶部栏属性设置为不透明

或尝试

self.navigationController.navigationBar.barStyle=UIBarStyleBlack不透明

或者检查一下这篇文章

tythis并将其放在每个ViewController类的
viewdidload
中:

    self.navigationController.navigationBar.translucent = NO;

我正在使用故事板:(我试过UIBarStyleBlack不透明,虽然白色电池和时间看起来不错,但白色栏仍然存在。故事板选项不存在,因为我使用的是导航控制器。我试过了,但白色仍然显示。这让我觉得半透明是否真的是我的问题。我宁愿不制作自定义导航栏。。