iOS 7 status bar back to iOS 6 default style in iPhone app?

前端 未结 25 1189
终归单人心
终归单人心 2020-11-22 05:48

In iOS 7 the UIStatusBar has been designed in a way that it merges with the view like this:

\"GUI

25条回答
  •  春和景丽
    2020-11-22 06:41

    In order to continue working with setStatusBarHidden: I use this category:

    @interface UIApplication (StatusBar)
    
    -(void)setIOS7StatusBarHidden:(BOOL)statusBarHidden;
    
    @end
    
    @implementation UIApplication (StatusBar)
    
    -(void)setIOS7StatusBarHidden:(BOOL)statusBarHidden{
        if (!IOS7) {
            [self setStatusBarHidden:statusBarHidden];
            return;
         }
    
        if ([self isStatusBarHidden] == statusBarHidden) {
            return;
        }
    
        [self setStatusBarHidden:statusBarHidden];
        [self keyWindow].clipsToBounds = YES;
        CGFloat offset = statusBarHidden ? 0 : 20;
        [self keyWindow].frame =  CGRectMake(0,offset,[self keyWindow].frame.size.width,[self keyWindow].frame.size.height-offset);
        [self keyWindow].bounds = CGRectMake(0, offset, [self keyWindow].frame.size.width,[self keyWindow].frame.size.height);
    }
    
    @end
    

提交回复
热议问题