IOS点击按钮隐藏状态栏详解及实例代码
程序员文章站
2024-02-15 20:18:16
ios点击按钮隐藏状态栏详解
前言:
最近学习ios的基础知识,实现隐藏状态栏的功能,这里就记录下来,希望对大家有所帮助
实例代码:
@interface...
ios点击按钮隐藏状态栏详解
前言:
最近学习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; }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!