IOS點(diǎn)擊按鈕隱藏狀態(tài)欄詳解
前言:
最近學(xué)習(xí)IOS的基礎(chǔ)知識,實(shí)現(xiàn)隱藏狀態(tài)欄的功能,這里就記錄下來,希望對大家有所幫助
實(shí)例代碼:
@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:@"隱藏導(dǎo)航欄" 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];//調(diào)用該方法后系統(tǒng)會調(diào)用prefersStatusBarHidden方法 self.hideStatus = !self.hideStatus;}- (BOOL)prefersStatusBarHidden{ return self.hideStatus;}
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選