iOS7导航栏半透明=否

我有一个背景图像,在所有的意见相同的图像,但导航栏traslucent默认设置为YES和背景是不均匀的。 我试过各种解决scheme,但没有改变:(

我的AppDelegate.h

#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end 

我的AppDelegate.m

 #import "AppDelegate.h" #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >>16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [[UINavigationBar appearance] setBarTintColor: UIColorFromRGB(0x45312a)]; [[UINavigationBar appearance] setTintColor: [UIColor whiteColor]]; NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; if ([[ver objectAtIndex:0] intValue] >= 7) { self.navigationController.navigationBar.translucent = NO; } return YES; } 

但在行中:

 self.navigationController.navigationBar.translucent = NO; 

给我这些错误:属性'导航控制器'找不到对象的types'AppDelegate *'

任何人都可以帮助我? 谢谢!

你可以在你的根视图控制器中做到这一点

 //inside the root view controller - (void)viewDidLoad { [super viewDidLoad]; [self.navigationController.navigationBar setTranslucent:NO]; } 

你也可以在界面生成器中切换半透明。 select您的导航控制器,然后在文档大纲中select导航栏,只需在属性检查器中进行更改

属性检查器导航栏

因为AppDelegate不是UINavigation控制器。 你可以做以前的工作就是全局设置导航栏外观。

 [[UINavigationBar appearance] setTranslucent:NO]; 

试试这个为ios 7

  [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];