Skip to content

Instantly share code, notes, and snippets.

@khorbushko
Created November 24, 2020 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khorbushko/20bbcf44eb4542eef20007bb231bf3ff to your computer and use it in GitHub Desktop.
Save khorbushko/20bbcf44eb4542eef20007bb231bf3ff to your computer and use it in GitHub Desktop.
struct NavigationBarAppearenceColor: ViewModifier {
init(backgroundColor: UIColor?, tintColor: UIColor) {
let appearence = UINavigationBarAppearance()
appearence.configureWithOpaqueBackground()
appearence.backgroundColor = backgroundColor
appearence.titleTextAttributes = [.foregroundColor: tintColor]
appearence.largeTitleTextAttributes = [.foregroundColor: tintColor]
UINavigationBar.appearance().standardAppearance = appearence
UINavigationBar.appearance().scrollEdgeAppearance = appearence
UINavigationBar.appearance().compactAppearance = appearence
UINavigationBar.appearance().tintColor = tintColor
}
func body(content: Content) -> some View {
content
}
}
extension View {
func naviagtionBarAppearenceConfigurationWith(
backgroundColor: UIColor?,
tintColor: UIColor) -> some View
{
modifier(
NavigationBarAppearenceColor(
backgroundColor: backgroundColor,
tintColor: tintColor
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment