How to hide the status bar programmatically in iOS 7?

后端 未结 12 1792
眼角桃花
眼角桃花 2020-12-05 17:00

In ios7, how can I hide the statusbar programmatically? I am using XCode 4.6.1 (ios6.1) and I want to implement this in XCode itself.

12条回答
  •  佛祖请我去吃肉
    2020-12-05 17:47

    In case of iOS >= 7.0 use following code :

    Syntax:

    // Present in UIViewController of UIKit Frameworks
    - (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0); // Defaults to NO
    

    Usage:

    - (BOOL)prefersStatusBarHidden {
        return YES;
    }
    

    In iOS < 7.0 use following code :

    Syntax:

    // Present in UIApplication of UIKit Frameworks
    - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation NS_AVAILABLE_IOS(3_2);
    

    Usage:

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

提交回复
热议问题