Created
May 26, 2017 07:30
-
-
Save levantAJ/f0c5cfb2ebb781970bafa5bbe0ea5fa7 to your computer and use it in GitHub Desktop.
Hide status bar with animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
var statusBarHidden: Bool = false { | |
didSet { | |
UIView.animate(withDuration: 0.25) { [weak self] in | |
self?.setNeedsStatusBarAppearanceUpdate() | |
} | |
} | |
} | |
override var prefersStatusBarHidden: Bool { | |
get { | |
return statusBarHidden | |
} | |
} | |
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { | |
get { | |
return .slide | |
} | |
} | |
func hideStatusBar() { | |
statusBarHidden = true | |
} | |
func showStatusBar() { | |
statusBarHidden = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment