Skip to content

Instantly share code, notes, and snippets.

@christianselig
Created October 20, 2021 15:54
Show Gist options
  • Save christianselig/97d04eafbdd8aeba1dd2f22131398a6e to your computer and use it in GitHub Desktop.
Save christianselig/97d04eafbdd8aeba1dd2f22131398a6e to your computer and use it in GitHub Desktop.
How to tweak the navigation bar color to make it consistent with system translucency when setting a color
if #available(iOS 15.0, *) {
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithDefaultBackground()
navigationBarAppearance.backgroundColor = UIColor(hexcode: "0C1019").withAlphaComponent(0.7)
navigationController!.navigationBar.standardAppearance = navigationBarAppearance
navigationController!.navigationBar.compactAppearance = navigationBarAppearance
navigationController!.navigationBar.scrollEdgeAppearance = navigationBarAppearance
} else {
navigationController!.navigationBar.barTintColor = UIColor(hexcode: "0C1019")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment