UIWindow中有相关层级设定的如下设置
- typedef CGFloat UIWindowLevel;
- const UIWindowLevel UIWindowLevelNormal; // 0.0
- const UIWindowLevel UIWindowLevelAlert; // 2000.0
- const UIWindowLevel UIWindowLevelStatusBar; // 1000.0
StatusBar的层级是1000 所以只需要将UIWindow层级设置为
UIWindowLevelAlert即可
然后接下来在改变层级的UIWindow中放置View便可以遮挡状态栏的位置了
继承 UIWindow, init的方法: 关键的语句 self.windowLevel=UIWindowLevelAlert;
- (id) init
{
CGRect f=[[UIScreen mainScreen] bounds];
CGRect s=[[UIApplication sharedApplication] statusBarFrame];
self = [super initWithFrame:CGRectMake(0, 0, f.size.width, s.size.height)];
if (self != nil) {
self.windowLevel=UIWindowLevelAlert;
self.backgroundColor=[UIColor clearColor];
[self makeKeyAndVisible];
}
return self;
}