最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
IOS点击按钮隐藏状态栏详解及实例代码
时间:2022-06-26 06:07:49 编辑:袖梨 来源:一聚教程网
IOS点击按钮隐藏状态栏详解
前言:
最近学习IOS的基础知识,实现隐藏状态栏的功能,这里就记录下来,希望对大家有所帮助
实例代码:
代码如下 | 复制代码 |
@interface SecondViewController () @property (nonatomic, assign,getter=isHideStatus)BOOLhideStatus; @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 { returnself.hideStatus; } |
相关文章
- 比特币交易量最大的交易所是哪个?全球最大的比特币交易平台排名 04-30
- 奥比岛梦想国度卡死闪退有哪些解决方法 04-30
- DNF手游骨戒在哪个位置 04-30
- 回望羊驼:当利空成为短暂的财富密码 04-30
- 为什么每个 Web3 项目都逃不过 DEX? 04-30
- HashKey Exchange 虚拟资产保险覆盖规模登顶全球第一 04-30