2016-11-16 15:10:14 u011496891 阅读数 1867

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


2016-03-04 12:40:53 sevenquan 阅读数 602

1、隐藏导航条

//    self.navigationController.navigationBarHidden = YES;//隐藏导航条

//    [self.navigationController setNavigationBarHidden:YES animated:YES]; //隐藏导航条


2、隐藏状态栏

-(BOOL)prefersStatusBarHidden

{

    //    [[UIApplication sharedApplication] setStatusBarHidden:YES];//ios9以后失效了

    return YES;

}


转载请注明出处 : http://write.blog.csdn.net/postedit

iOS交流群:496146057

2016-08-10 10:35:18 zhonggaorong 阅读数 1033

显示app状态栏

[[UIApplication sharedApplication]setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];

隐藏app状态栏


[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];


2017-04-26 15:46:58 CC1991_ 阅读数 1410

今天在做webView跳转的时候,遇到一个涉及状态栏的问题,这里就分享一下隐藏状态栏的方法。

一、整个项目隐藏状态栏。

在Targets->General->勾选Hide status bar即可。

 

二、单一某个界面隐藏状态栏的方法,比如个人中心、登录、注册等界面。

1.首选需要在info.plist里面添加 View controller-based status bar appearance选项,并且设置为 NO;

2.在需要改变状态栏的ViewController类中添加以下代码:

//生命周期--进入时隐藏
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
//隐藏:YES,  显示:NO,  Animation:动画效果
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
//生命周期--退出时显示
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
//隐藏:YES, 显示:NO ,Animation:动画效果
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

 

三、启动界面隐藏状态栏,进入程序后正常显示状态栏。

1.这个相当于综合了上面两个方法,首先需要在Targets->General->勾选Hide status bar 或者 在info.plist里面添加 View controller-based status bar appearance选项,并且设置为 NO;

2.在AppDelegate.m文件中添加以下代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}

 

隐藏状态栏ios

阅读数 692

iOS隐藏状态栏

阅读数 243

没有更多推荐了,返回首页