Chris
Chris

Reputation: 581

iOS 7 status bar back to iOS 6 style's issue

I use the way here:

https://stackoverflow.com/a/18387241/2717264

everything ok, but when I presentViewController a UIImagePickerController, the window show like this:

enter image description here

than, I custom a pickerController subclass from UIImagePickerController, in the pickerController viewDidLoad add this code:

#define AppDelegate ((WeikeAppDelegate *)[[UIApplication sharedApplication] delegate])

AppDelegate.window.clipsToBounds = NO;
AppDelegate.window.frame =  CGRectMake(0, 0, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height + 20);
AppDelegate.window.bounds = CGRectMake(0, 0, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height);

it work fine, but when pickerController dismiss, window display incorrect again:

enter image description here

I try to solve it by adding this code in the viewWillDisappear of pickerController, but useless, any idea?

AppDelegate.window.clipsToBounds = YES;
AppDelegate.window.frame =  CGRectMake(0, 20, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height -20);
AppDelegate.window.bounds = CGRectMake(0, 20, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height);

Upvotes: 1

Views: 690

Answers (2)

Chris
Chris

Reputation: 581

I have solved it by doing lots of test, I set a 640*128(pixels) image as the background of the navigationbar, this is the image(40 pixels height black block as the statuebar and 88 pixels height block as the navigationbar):

enter image description here

then it display Correct in case of UIImagePickerControllerSourceTypeCamera,if u presentViewController the UIImagePickerController in the case of UIImagePickerControllerSourceTypePhotoLibrary(I think this will be also Suitable for presentViewController the other view controller with a navigationbar, but I haven't do a test yet), u should subclass from UIImagePickerController:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}


- (void)viewWillDisappear:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

Prerequisites:

have this code in the your first view controller:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad
{
    /*navigation config*/
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image-navigation-bk"]
                                                  forBarMetrics:UIBarMetricsDefault];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
    {
        [self setNeedsStatusBarAppearanceUpdate];
    }
}

Upvotes: 0

SampathKumar
SampathKumar

Reputation: 2545

Xcode 5 has iOS 6/7 Deltas which is specifically made to resolve this issue. In the storyboard, I moved my views 20 pixels down to look right on iOS 7 and in order to make it iOS 6 compatible, I changed Delta y to -20.

enter image description here

Since my storyboard is not using auto-layout, in order to resize the height of views properly on iOS 6 I had to set Delta height as well as Delta Y.

Upvotes: 2

Related Questions