Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mycroftcanner/4fd9b3c1788dd2f592b40074056ebcc7 to your computer and use it in GitHub Desktop.
Save mycroftcanner/4fd9b3c1788dd2f592b40074056ebcc7 to your computer and use it in GitHub Desktop.
SwiftUI hack: NavigationView and TabView's appearance
// SwiftUI hack: NavigationView and TabView's appearance
import UIkit
extension UINavigationController {
override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
navigationBar.standardAppearance = appearance
navigationBar.compactAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
}
}
extension UITabBarController {
override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
tabBar.standardAppearance = appearance
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment