Frage

I'm using a UINavigationController

for rootViewController, I make the navigationBar to transparent

enter image description here

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

The problem is, when I navigate to 2nd viewController

enter image description here

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

Here I set the navigationBar color back to green, but the status bar doesn't appear in green background.

Is that possible to change the status bar background to green?

War es hilfreich?

Lösung 2

write this in didFinishLaunchingWithOptions method of 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;
}

and write following code where you set background color of status bar. first create object of appdelegate and call using that.

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

Refer this:

Andere Tipps

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

Try this link also

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top