Saturday, November 7, 2026
HomeiOS Developmentios - The way to prolong a MapKit's Map past NavigationBar and...

ios – The way to prolong a MapKit’s Map past NavigationBar and TabBar in SwiftUI?

[ad_1]

I’m engaged on a SwiftUI app which makes use of each TabView and NavigationView. One of many views is accountable for presenting a Map from MapKit and it’s meant to take all out there area. I would really like it to increase past TabBar and NavigationBar, in order that I can see the map’s content material via the bars’ customary translucent materials, similar to on this screenshot from the Apple Retailer app:

Apple Retailer App Screenshot

I attempted utilizing .ignoresSafeArea() modifier on the Map, however then the bars had no background materials in any respect, simply the buttons and navigation title have been seen, like this:

Demo View Screenshot

It would not appear to be an issue particular to the construction of my app – I attempted making a brand new, unbiased view with these two bars and nonetheless obtained the identical outcomes. Right here is the code of that pattern view:

import MapKit
import SwiftUI

struct SwiftUIView: View {
    @State non-public var area = MKCoordinateRegion(
        middle: CLLocationCoordinate2D(latitude: 50, longitude: 20),
        span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
    )
    
    var physique: some View {
        TabView {
            NavigationView {
                Map(coordinateRegion: $area)
                    .ignoresSafeArea()
                    .navigationTitle("Map")
            }
            .tabItem {
                Label("Map", systemImage: "map")
            }
        }
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        SwiftUIView()
    }
}

Is there one thing vital I’m lacking or is there a bug within the Map part?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments