Skip to content

Instantly share code, notes, and snippets.

@levantAJ
Created May 26, 2017 07:30
Show Gist options
  • Save levantAJ/f0c5cfb2ebb781970bafa5bbe0ea5fa7 to your computer and use it in GitHub Desktop.
Save levantAJ/f0c5cfb2ebb781970bafa5bbe0ea5fa7 to your computer and use it in GitHub Desktop.
Hide status bar with animation
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