Ask Your Question
0

What is the technique to expand a SwiftUI MapKit's Map beyond the NavigationBar and TabBar?

asked 2023-02-06 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-15 14:00:00 +0000

lalupa gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-02-06 11:00:00 +0000

Seen: 11 times

Last updated: May 15 '21