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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-02-06 11:00:00 +0000
Seen: 11 times
Last updated: May 15 '21
How to add a custom button in SwiftUI for iOS13 that enables going back between screens?
How can the update of properties from both ParentViewModel and ChildViewModel in SwiftUI be solved?
Can SwiftUI be utilized to restrict the touch region for a drag gesture?
How can the color of a selected element (Picker) be modified in SwiftUI for WatchOS?
How to make a calendar layout that is horizontal using Swiftui?
What is the process to add a radio button with a check mark on a TableView cell using Swift?
How to limit UITextField input to only accept numerical values?