SwiftUI List/ScrollView x MapKit – Map adds gradient/material toolbar (navigation bar) and overrides its design

I’m working on iOS 17+ app in SwiftUI, which uses MapKit.
MapKit’s Map view adds a gradient/material view on Toolbar, which is presented on second and every next navigation.

I would like to get the first’s navigation behavior, which is no background and no shadow image (navbar divider).

This issue is 100% related to the Map view – commenting it out resolves the issue, but also removes the functionality, which I need.

Code:

struct HomeView: View {
    var body: some View {
        NavigationStack {
            Content(/* properties */)
        }
    }
}

struct Content: View {
    // Properties ...

    var body: some View {
        Group {
            if array.isEmpty {
                EmptyStateView()
            } else {
                ListView(data: array, onDelete: onDelete)
            }
        }
        .accentBackground(strong: true) // << Gradient background
        .navigationTitle("Title")
        .toolbar {
            ToolbarItem(placement: .topBarTrailing) {
                AddButton()
            }
        }
    }
}

struct ListView: View {
    // Properties ...

    var body: some View {
        List {
            ForEach(data) { list in
                Row(/* properties */)
            }
            .onDelete(perform: onDelete)
        }
        .scrollContentBackground(.hidden)
    }
}

struct Row: View {
    // Properties ...

    var body: some View {
        NavigationLink(destination: DetailsView(list: list)) {
            VStack(alignment: .leading) {
                Text(list.title)
                    .font(.headline)
                Text(/* sublabel */)
                    .font(.subheadline)
                    .foregroundStyle(.secondary)
            }
        }
    }
}

struct DetailsView: View {
    // Properties ...

    var body: some View {
        List {
            // Some conditional subviews ...

            if let location = list.location {
                Section {
                    // Edit mode conditional remove button ...

                    PresentableMap(location: location)
                        .frame(height: 300)
                }
            }
        }
        .scrollContentBackground(.hidden)
        .accentBackground(strong: true)
        .navigationTitle(list.title)
    }
}

struct PresentableMap: View {
    let location: ListLocation

    private var coordinates: CLLocationCoordinate2D {
        .init(latitude: location.latitude, longitude: location.longitude)
    }

    var body: some View {
        // MapKit View ⬇️
        Map(position: .constant(.camera(.init(centerCoordinate: coordinates, distance: 200))), selection: .constant(location)) {
            Marker(coordinate: coordinates) {
                Image(systemName: "mappin")
            }
        }
        .clipShape(RoundedRectangle(cornerRadius: 8))
        .allowsHitTesting(false)
    }
}

What I tried:

  • .toolbarBackground(.hidden, for: .navigationBar) and other SwiftUI modifiers for hidden navbar background – resolves the issue, but also removes the toolbar background for inline navbar, which is presented during scroll. I would like to keep the large title style and present inline navbar only during scroll.
    Screenshot of the bugged scroll:
  • Overriding UINavigationBarAppearance – breaks whole app.
  • Overriding UINavigationBar by its properties using SwiftUIIntrospect – can be used only on the NavigationStack, which leds to the breaking Home and Details views, similar behavior to the first point. Can’t Introspect navigation controller on Map view – I can only Introspect Map, which is MKMapView, which is UIView, which doesn’t have access to NavigationController and its NavigationBar. inputViewController or inputAccessoryViewController are nil.
  • Changing the toolbar color to red (which I don’t like, but shows how the app behaves; I don’t want to use any color, even matching one, because it results in the ugly design, where the space is anyway divided and doesn’t match the linear gradient background):

On the gif above you can see that overriding the background respects the safe area, however, the toolbar material added by Map view ignores the safe area.

What do I expect:

  • If that’s possible, I would like to keep the List (+its current style) and native NavigationBar with large title.
  • Such behavior:

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật