To expand a SwiftUI MapKit's Map beyond the NavigationBar and TabBar, you can embed the map in a ZStack and set the edgesIgnoringSafeArea to .all:
struct ContentView: View {
var body: some View {
ZStack {
MapView()
.edgesIgnoringSafeArea(.all)
VStack {
Text("Map Title")
.font(.largeTitle)
.foregroundColor(.white)
.padding()
Spacer()
}
}
}
}
struct MapView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
MKMapView(frame: .zero)
}
func updateUIView(_ uiView: MKMapView, context: Context) {
}
}
This will allow the map to extend beyond the safe area and fill the entire screen.
Asked: 2023-02-06 11:00:00 +0000
Seen: 11 times
Last updated: May 15 '21