I study related iOS 7 status-Bar Maintain, but am I facing an issue while I am using UIImagePickerController
. Allow editing that Editing Window shows 20 pixels space at the top bar.
I used the code and first I set UIViewControllerBasedStatusBarAppearance
to NO
in info.plist
and set the delegate method:
Appdelegate.h
@property (retain, nonatomic) UIWindow *background;
Appdelegate.m
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
background = [[UIWindow alloc] initWithFrame: CGRectMake(0, 0, self.window.frame.size.width, 20)];
background.backgroundColor =[UIColor redColor];
[background setHidden:NO];
}
In my home view controller that has no effect, so I put in my home viewController, one method for changing the background color of statusbar:
-(void)viewWillLayoutSubviews{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
self.view.clipsToBounds = YES;
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenHeight = screenRect.size.height;
self.view.frame = CGRectMake(0, 20, self.view.frame.size.width,screenHeight-20);
self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"userIsMale"]) {
[tempWindow setBackgroundColor:[UIColor colorWithRed:(46.0/255.0) green:(134.0/255.0) blue:(255.0/255.0) alpha:1]];
}
else {
[tempWindow setBackgroundColor:[UIColor colorWithRed:(246.0/255.0) green:(26.0/255.0) blue:(113.0/255.0) alpha:1]];
}
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
Now when I present UIImagePickerController
allow editing window that shows it like this:
I tried with this solution for hide statusbar while present UIImagePickerController
:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
And show status bar code in ViewWillApear
.
I got this type of result:
Where am I doing wrong and how do I solve this?