user2893370
user2893370

Reputation: 711

set Status Bar Color as Black in IOS 7

In my app I am set the image of navigationBar.

But I want to status bar as defaultBlack as ios6.

My code is as follow:

NSString *ver = [[UIDevice currentDevice] systemVersion];
    int ver_int = [ver intValue];
    NSString* toReturn=@"";
       toReturn = @"logo_bar.png";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:toReturn] forBarMetrics:UIBarMetricsDefault];

Help me to solve this.

Upvotes: 1

Views: 915

Answers (5)

lennartk
lennartk

Reputation: 619

first, change View controller-based status bar appearance in your info.plist to YES. Then use

-(UIStatusBarStyle)preferredStatusBarStyle {
     return UIStatusBarStyleDefault;
}

Upvotes: 0

Amit
Amit

Reputation: 283

In view did load check if OS version is 7 or greater. Then add uiview with background colour as black and with height at the top of the view controller.

Upvotes: 1

devops
devops

Reputation: 9179

do it in

- (void)viewDidLoad{
  [super viewDidLoad];

  [self.navigationController.navigationBar
        setBackgroundImage:[UIImage imageNamed:@"logo_bar.png"]
        forBarMetrics:UIBarMetricsDefault];

  //...
}

or try this to set it to all navbars in you AppDelegate#didFinishLaunchingWithOptions method

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo_bar.png"]forBarMetrics:UIBarMetricsDefault];

make sure you are follows the rules for Creating Resizable Images

Upvotes: 0

v1shnu.mee
v1shnu.mee

Reputation: 122

If your image size is 320x64 try an image with size 320x44.I Hope this helps.

Upvotes: 0

iBhavin
iBhavin

Reputation: 1261

Just add this code:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {
        [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
    }

Upvotes: 0

Related Questions