setStatusBarHidden(_:withAnimation:) deprecated in iOS 9

后端 未结 5 1850
遥遥无期
遥遥无期 2020-12-13 01:39

I see that in iOS 9 setStatusBarHidden(_:withAnimation:) is now deprecated and the documentation says to use [UIViewController prefersStatusBarHidden]

5条回答
  •  孤城傲影
    2020-12-13 02:26

    if you are coding with objective c, Here is the solution :)(Leo's Objective C version :P thanks man!!!)

    declare a variable

    bool isHidden;
    isHidden = false;//in viewDidload()
    

    and then add this code when you want to hide status bar

    isHidden = true;
    [UIView animateWithDuration:0.6 animations:^{
        [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    }];
    

    after that add this two method

    -(UIStatusBarAnimation) preferredStatusBarUpdateAnimation
    {
    return UIStatusBarAnimationFade;
    }
    
    -(BOOL) prefersStatusBarHidden
    { return isHidden;}
    

    Hope your problem will be solve (smile)

提交回复
热议问题