遮住状态栏

UIView *statusView = [[UIView alloc] initWithFrame:[[UIApplication sharedApplication] statusBarFrame]];
statusView.backgroundColor = [UIColor blackColor];
UIWindow *wd = [self mainWindow];
//添加遮盖视图
[wd addSubview:statusView];
//修改窗口等级
wd.windowLevel = UIWindowLevelAlert;
/**
 获取window
 */
- (UIWindow*)mainWindow{
    UIApplication *app = [UIApplication sharedApplication];
    if ([app.delegate respondsToSelector:@selector(window)]) {
        return [app.delegate window];
    } else {
        return [app keyWindow];
    }
}

你可能感兴趣的:(遮住状态栏)