亲宝软件园·资讯

展开

IOS点击按钮隐藏状态栏 IOS点击按钮隐藏状态栏详解及实例代码

人气:0
想了解IOS点击按钮隐藏状态栏详解及实例代码的相关内容吗,在本文为您仔细讲解IOS点击按钮隐藏状态栏的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:iOS点击按钮隐藏状态栏,IOS,状态栏隐藏实现代码,IOS,隐藏状态栏,下面大家一起来学习吧。

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;
}

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

加载全部内容

相关教程
猜你喜欢
用户评论