1

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.

user2893370
  • 701
  • 9
  • 22
  • possible duplicate of [How to change Status Bar text color in iOS 7.](http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7) – Ryan Jul 10 '14 at 08:22

5 Answers5

1

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.

Amit
  • 283
  • 2
  • 16
0

Just add this code:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {
        [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
    }
iBhavin
  • 1,886
  • 15
  • 30
0

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

v1shnu.mee
  • 122
  • 1
  • 1
  • 8
0

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

dieter
  • 8,413
  • 5
  • 43
  • 69
0

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

-(UIStatusBarStyle)preferredStatusBarStyle {
     return UIStatusBarStyleDefault;
}
lennartk
  • 451
  • 1
  • 4
  • 15