<分区>
我有一个 UINavigationBar,它在应用程序委托(delegate)类中设置了背景图像,因此您可以想象为什么我不希望 Navigationbar 是半透明的。我相信这是罪魁祸首:http://imgur.com/v3e0NIo
无论如何,当我放置这行代码时:
[[UINavigationBar appearance] setTranslucent:NO];
在我的 AppDelegate 中我遇到了这个错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, B for appearance setter, _installAppearanceSwizzlesForSetter:'
即使我尝试在每个类中单独使每个 UINavigationbar 不透明,图像中仍然有那个愚蠢的白色条!虽然没有抛出任何错误,这让我想知道代码是否不起作用,或者透明度是否不是我的问题?
谢谢!
编辑:
这是我在我的 AppDelegate 中用来为 NavBar 制作自定义背景的代码:
[[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 的背景设为黑色,白色条仍然存在。我现在非常怀疑透明度是我的问题!