Reputation: 458
I have a trouble when trying to add a new window manually into screen when already presented UIImagePicker (images bellow). The purpose is, replace current status bar by new one. Then I can control which content is displayed on that.
After adding, UIImagePicker has been dismissed and presenting screen is displayed with no status bar and no new status bar.
And here is my code, just simple few lines of code
_newWindow = [[UIWindow alloc] initWithFrame:[UIApplication sharedApplication].statusBarFrame];
UIView *_newView = [[[NSBundle mainBundle] loadNibNamed:@"NewStatusView" owner:self options:nil] firstObject];
_newView.frame = [UIApplication sharedApplication].statusBarFrame;
[_newWindow addSubview:_newView];
_newWindow.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
_newWindow.windowLevel = UIWindowLevelAlert + 1;
_newWindow.hidden = NO;
Update: here is what I expected:
I would like to create the red zone that displays on top of all view controllers, image pickers, alert controllers, presented view controllers, etc... and it lays on on all project screens. So i decided to use new window for that.
Upvotes: 0
Views: 50
Reputation: 11343
You can use this method to show/hide the status bar:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
No need to add a view beneath it.
Update:
You may subclass UINavigationBar
to keep the size of it 64px like this:
#import "TANavigationBar.h"
@implementation TANavigationBar
- (CGSize)sizeThatFits:(CGSize)size {
CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGSize newSize = CGSizeMake(width, 64);
return newSize;
}
@end
Later on you can use this navigation bar when you initialize your navigation controller like this:
UINavigationController* nvc= [[UINavigationController alloc] initWithRootViewController:viewController];
[nvc setValue:[[TANavigationBar alloc]init] forKeyPath:@"navigationBar"];
This way you will not lose the status bar margin.
Upvotes: 1