使用「;UINavigationBar外观设置半透明:否“;在iOS 7中

使用「;UINavigationBar外观设置半透明:否“;在iOS 7中,ios,uinavigationcontroller,uinavigationbar,tintcolor,Ios,Uinavigationcontroller,Uinavigationbar,Tintcolor,我在AppDelegate中定义我的UINavigationBar颜色代码时使用了: [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]]; [[UINavigationBar appearance] setTranslucent:NO]; [[UINavigationBar appeara

我在
AppDelegate
中定义我的
UINavigationBar
颜色代码时使用了:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setTranslucent:NO];
然后,我还将我的
导航栏的
半透明
设置为:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setTranslucent:NO];
我的项目的
部署目标是iOS 7和
目标SKD
iOS 8。只有当我在任何iOS 7设备上运行该项目时,它才会崩溃。挖了一点后,我发现
[[UINavigationBar外观]set半透明:否]在iOS 7中不起作用。所以我想知道“除了在本地调用它(在每个
viewController
)”
有没有办法在iOS 7到iOS 8中使用它


提前非常感谢。

您可以通过使用不存在的映像来实现这一点,该映像会愚弄编译器,如:-

[[UIToolbar appearance] setBackgroundImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
而不是: