iOS 9隐藏状态栏动画setStatusBarHidden(_:withAnimation:) deprecated

原创Blog,转载请注明出处
http://blog.csdn.net/hello_hwc?viewmode=list
我的stackoveflow

源自自己的一个StackOverflow答案
http://stackoverflow.com/a/32808743/3940672

解决办法
使用preferredStatusBarUpdateAnimation

GIf

代码

class ViewController: UIViewController {
var isHidden:Bool = false
@IBAction func clicked(sender: AnyObject) {
    isHidden = !isHidden
    UIView.animateWithDuration(0.5) { () -> Void in
        self.setNeedsStatusBarAppearanceUpdate()
    }
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
    return UIStatusBarAnimation.Slide
}
override func prefersStatusBarHidden() -> Bool {
    return isHidden
}
}

你可能感兴趣的:(ios,StatusBar)