Search code examples
iosios7uikitstatusbar

How to change status background to be different from Navigation bar on iOS 7?


I try to make status bar background as iOS6 version. I want to use a custom color as Red or Blue color rather than Light or Default status bar background.

How about switching all text color of status bar from black to white and vice versa programmatically.

I found out that it changed after I change the value of "View controller-based status bar appearance" to YES or NO. Please give me the way to change its value programmatically.


Solution

  • Add this code in viewDidLoad of your projects Base class

    UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, 320, 22)];
    statusBarView.backgroundColor = [UIColor redColor];
    [self.navigationController.navigationBar addSubview:statusBarView];