Search code examples
iosiphoneios7statusbar

Status bar backgroundColor


I am using ios 7 I want to set stauts bar background image. I have done this but still it is not changing anything:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
    UIView *addStatusBar = [[UIView alloc] init];
    addStatusBar.frame = CGRectMake(0, 0, 320, 20);
    addStatusBar.backgroundColor = [UIColor redColor]; //change this to match your navigation bar
    [self.window.rootViewController.view addSubview:addStatusBar];
}

Solution

  • your code works, but you have to modify it a bit. here is what it should look like..

    // 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 colorWithPatternImage:[UIImage imageNamed:@"bg1.png"]];
    //here you are adding the image as the background image
        [self.window.rootViewController.view addSubview:addStatusBar];
    

    don't forget to import your image to the project. now i have just plugged in the above code in application didfinishwithoptions of the app delegate, but you should be able to use the same if you want different views using the same. enter image description here