2014-03-07 42 views
2

我使用的是UINavigationControllerUIStatusBar在iOS7改变颜色

rootViewController,我做的导航栏,以透明

enter image description here

[self.view setBackgroundColor:[UIColor greenColor]]; 
self.navigationController.navigationBar.shadowImage = [UIImage new]; 
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; 

的问题是,当我浏览到第2的viewController

enter image description here

[self.navigationController.navigationBar setBackgroundColor:[UIColor greenColor]]; 

这里我设置navigationBar颜色回绿色,但状态栏没有出现在绿色背景中。

是否有可能将状态栏背景改为绿色?

回答

2

写的AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 

    // Override point for customization after application launch. 
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { 
     UIView *addStatusBar = [[UIView alloc] init]; 
     addStatusBar.frame = CGRectMake(0, 0, 320, 20); 
     //change this to match your navigation bar or view color or tool bar 
     //You can also use addStatusBar.backgroundColor = [UIColor BlueColor]; or any other color 
     addStatusBar.backgroundColor = [UIColor colorWithRed:0.973.0/255. green:0.973.0/255. blue:0.973.0/255. alpha:1]; 
     [self.window.rootViewController.view addSubview:addStatusBar]; 
    } 
    return YES; 
} 

的这didFinishLaunchingWithOptions方法,写在其中设置状态栏的背景颜色以下代码。首先创建appdelegate的对象并使用该对象进行调用。

appdelegate.addStatusBar.backgroundColor = [UIColor colorWithRed:85.0/255.0 green:85.0/255.0 blue:85.0/255.0 alpha:1]; 

Refer this:

3
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)]; 

试试这个link