iOS点击按钮隐藏状态栏

Posted JoySeeDog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS点击按钮隐藏状态栏相关的知识,希望对你有一定的参考价值。


@interface SecondViewController ()
@property (nonatomic, assign,getter=isHideStatus) BOOL hideStatus;
@end

@implementation SecondViewController

- (void)viewDidLoad 
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    UIButton *button  = [[UIButton  alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
    button.center = self.view.center;
    button.backgroundColor = [UIColor blueColor];
    [button setTitle:@"隐藏导航栏" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(hideFrame) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];

    self.hideStatus = [UIApplication sharedApplication].statusBarHidden;

    // Do any additional setup after loading the view, typically from a nib.



- (void)hideFrame 

    [self setNeedsStatusBarAppearanceUpdate];//调用该方法后系统会调用prefersStatusBarHidden方法
    self.hideStatus = !self.hideStatus;


- (BOOL)prefersStatusBarHidden

    return self.hideStatus;



以上是关于iOS点击按钮隐藏状态栏的主要内容,如果未能解决你的问题,请参考以下文章

在 Flutter 中隐藏/删除状态栏(点击按钮)

IOS - Firebase 动态链接打开应用但在状态栏上显示文本按钮

安卓 /android 手机 隐藏 状态栏 怎么操作啊

android关掉导航栏后怎么

如何使用点击手势(iOS8 / Swift)在 pageViewController 上显示/隐藏状态栏

检查使用模态视图控制器隐藏的 iOS 状态栏