iPhone - Remove status bar programmatically

前端 未结 6 1777
刺人心
刺人心 2021-01-02 09:17

I have made an app that implements the iPhone\'s camera. When the user finishes picking their image, the status bar reappears! How would I make sure that the status bar sta

6条回答
  •  余生分开走
    2021-01-02 09:52

    With iOS 7 and later, you can use the following code to hide and unhide the status bar,

    @interface ViewController()
    
    @property (nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden;
    
    @end
    
    @implementation ViewController
    
    
      ... other codes
    
    - (BOOL)prefersStatusBarHidden {
        return self.isStatusBarHidden;
    }
    
    - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
        return UIStatusBarAnimationFade;
    }
    
    - (void)hideStatusBar {
        self.statusBarHidden = YES;
        [self setNeedsStatusBarAppearanceUpdate];
    }
    
    - (void)showStatusBar {
        self.statusBarHidden = NO;
        [self setNeedsStatusBarAppearanceUpdate];
    }
    
    @end
    

提交回复
热议问题