iOS点击按钮隐藏状态栏

来源:互联网 发布:windows phone 10安卓 编辑:程序博客网 时间:2024/06/06 01:13
@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;}
0 0