Skip to content

Instantly share code, notes, and snippets.

@jimbrayrcp
Last active July 11, 2023 01:52
Show Gist options
  • Save jimbrayrcp/2fe46ca617ea798a0b9f7e10c77bfa40 to your computer and use it in GitHub Desktop.
Save jimbrayrcp/2fe46ca617ea798a0b9f7e10c77bfa40 to your computer and use it in GitHub Desktop.
Swift 5: iOS: 13.1 removes the navigation bar on a per-viewcontroller basis. Use this method if you want to show full screen image with no navigation bar obscuring your view. Title and Prompt can be added if desired
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Provide a clear background for the navigaion bar
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Restore default navigation bar before exiting view
navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
navigationController?.navigationBar.shadowImage = nil
}
@aehlke
Copy link

aehlke commented Jul 11, 2023

this now crashes on the UIImage() line under the iOS update that released today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment