When adding a Map
using the MapKit
this changes the appearance of the NavigationView and the TabBar.
I have tried adding the following modifier to the Map
<code>.toolbarBackground(Color("White"), for: .navigationBar)
</code>
<code>.toolbarBackground(Color("White"), for: .navigationBar)
</code>
.toolbarBackground(Color("White"), for: .navigationBar)
But the navigation toolbar still has a shadow, and the TabBar has the default translucent background colour with shadow.
Root
<code>init() {
// this is not the same as manipulating the proxy directly
let appearance = UINavigationBarAppearance()
// this overrides everything you have set up earlier.
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
//In the following two lines you make sure that you apply the style for good
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
UITabBar.appearance().barTintColor = UIColor.white)
UITabBar.appearance().backgroundColor = UIColor.white)
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
UINavigationBar.appearance().isTranslucent = false
UIToolbar.appearance().backgroundColor = UIColor.white)
UIToolbar.appearance().isTranslucent = false
UIToolbar.appearance().setShadowImage(UIImage(), forToolbarPosition: .any)
}
struct MainView: View {
var body: some View {
TabView {
ContentView()
.tabItem {
Label("Menu", systemImage: "list.dash")
}
}
}
}
</code>
<code>init() {
// this is not the same as manipulating the proxy directly
let appearance = UINavigationBarAppearance()
// this overrides everything you have set up earlier.
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
//In the following two lines you make sure that you apply the style for good
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
UITabBar.appearance().barTintColor = UIColor.white)
UITabBar.appearance().backgroundColor = UIColor.white)
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
UINavigationBar.appearance().isTranslucent = false
UIToolbar.appearance().backgroundColor = UIColor.white)
UIToolbar.appearance().isTranslucent = false
UIToolbar.appearance().setShadowImage(UIImage(), forToolbarPosition: .any)
}
struct MainView: View {
var body: some View {
TabView {
ContentView()
.tabItem {
Label("Menu", systemImage: "list.dash")
}
}
}
}
</code>
init() {
// this is not the same as manipulating the proxy directly
let appearance = UINavigationBarAppearance()
// this overrides everything you have set up earlier.
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
//In the following two lines you make sure that you apply the style for good
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
UITabBar.appearance().barTintColor = UIColor.white)
UITabBar.appearance().backgroundColor = UIColor.white)
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
UINavigationBar.appearance().isTranslucent = false
UIToolbar.appearance().backgroundColor = UIColor.white)
UIToolbar.appearance().isTranslucent = false
UIToolbar.appearance().setShadowImage(UIImage(), forToolbarPosition: .any)
}
struct MainView: View {
var body: some View {
TabView {
ContentView()
.tabItem {
Label("Menu", systemImage: "list.dash")
}
}
}
}
The Tabbar has a solid white colour with no shadow, as well as navigation bars.
Content View
<code>struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: MapView()) {
Text("Hello, World!")
}
}
.navigationTitle("Content")
}
}
</code>
<code>struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: MapView()) {
Text("Hello, World!")
}
}
.navigationTitle("Content")
}
}
</code>
struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: MapView()) {
Text("Hello, World!")
}
}
.navigationTitle("Content")
}
}
MapView
<code>struct MapView: View {
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
var body: some View {
Map(coordinateRegion: $region)
.frame(width: 400, height: 300)
}
}
</code>
<code>struct MapView: View {
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
var body: some View {
Map(coordinateRegion: $region)
.frame(width: 400, height: 300)
}
}
</code>
struct MapView: View {
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
var body: some View {
Map(coordinateRegion: $region)
.frame(width: 400, height: 300)
}
}