Skip to content

Instantly share code, notes, and snippets.

@PetreVane
Last active January 24, 2020 17:18
Show Gist options
  • Save PetreVane/0c7d2031fed002704e3500728cb12f16 to your computer and use it in GitHub Desktop.
Save PetreVane/0c7d2031fed002704e3500728cb12f16 to your computer and use it in GitHub Desktop.
Hides the Navigation Bars on tap
override func viewWillAppear(_ animated: Bool) {
uper.viewWillAppear(animated)
navigationController?.hidesBarsOnTap = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.hidesBarsOnTap = false
}
/*
if that returns true, the home indicator will disappear after a couple of seconds, only to automatically reappear when the user touches the screen.
*/
navigationController?.navigationBar.prefersLargeTitles = true
/*
We’re going to write this method so that it returns the value of our navigation controller’s hidesBarsOnTap property, meaning that the bars and the home indicator should disappear or reappear together.
*/
override var prefersHomeIndicatorAutoHidden: Bool {
return navigationController?.hidesBarsOnTap ?? false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment