Skip to content

Instantly share code, notes, and snippets.

@apatronl
Created July 2, 2020 21:06
Show Gist options
  • Save apatronl/29b6c82085afd1c6177715d88411aaf4 to your computer and use it in GitHub Desktop.
Save apatronl/29b6c82085afd1c6177715d88411aaf4 to your computer and use it in GitHub Desktop.
import SwiftUI
import UIKit
struct NavigationBarColor: ViewModifier {
init(backgroundColor: UIColor, tintColor: UIColor) {
let coloredAppearance = UINavigationBarAppearance()
coloredAppearance.configureWithOpaqueBackground()
coloredAppearance.backgroundColor = backgroundColor
coloredAppearance.titleTextAttributes = [.foregroundColor: tintColor]
coloredAppearance.largeTitleTextAttributes = [.foregroundColor: tintColor]
UINavigationBar.appearance().standardAppearance = coloredAppearance
UINavigationBar.appearance().scrollEdgeAppearance = coloredAppearance
UINavigationBar.appearance().compactAppearance = coloredAppearance
UINavigationBar.appearance().tintColor = tintColor
}
func body(content: Content) -> some View {
content
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment