首页 > 代码库 > 隐藏状态栏

隐藏状态栏

在info.plist 添加两个键

View controller-based status bar appearance   YES

Status bar is initially hidden  NO

 

代码中在要隐藏状态栏的地方(UIViewController 中)

@property (nonatomic, getter = isStatusBarHidden) BOOL statusBarHidden;

 

#pragma mark - 隐藏状态栏#pragma mark - Private-  (BOOL)prefersStatusBarHidden {    return  self.statusBarHidden ;}- (void)toggleStatusBarHiddenWithAppearanceUpdate:(BOOL)updateAppearance{    self.statusBarHidden = updateAppearance;    [UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{            [self setNeedsStatusBarAppearanceUpdate];        }];    }

 

 

[self  toggleStatusBarHiddenWithAppearanceUpdate:YES];

[self  toggleStatusBarHiddenWithAppearanceUpdate:NO];

 

 

隐藏状态栏