Detailed explanation of IOS click button to hide the status bar
Preface:
I have recently learned the basic knowledge of IOS and implemented the function of hiding the status bar. I will record it here, hoping it will be helpful to everyone.
Example code:
@interface SecondViewController () @property (nonatomic, assign,getter=isHideStatus) BOOL hideStatus; @end @implementation SecondViewController - (void)viewDidLoad { [super viewDidLoad]; = [UIColor whiteColor]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 300, 200)]; = ; = [UIColor blueColor]; [button setTitle:@"Hide navigation bar" forState:UIControlStateNormal]; [button addTarget:self action:@selector(hideFrame) forControlEvents:UIControlEventTouchUpInside]; [ addSubview:button]; = [UIApplication sharedApplication].statusBarHidden; // Do any additional setup after loading the view, typically from a nib. } - (void)hideFrame { [self setNeedsStatusBarAppearanceUpdate];//After calling this method, the system will call the prefersStatusBarHidden method = !; } - (BOOL)prefersStatusBarHidden { return ; }
Thank you for reading, I hope it can help you. Thank you for your support for this site!