Интеграция SwiftUI + MapBox портит навигационную панель - PullRequest
0 голосов
/ 03 мая 2020

Я реализую некоторые функции MapBox в SwiftUi, и при использовании панели навигации по умолчанию все работает как положено:

var body: some View {
        NavigationView {
            MapView(annotations: $annotations)
                .centerCoordinate(.init(latitude: 37.791293, longitude: -122.396324))
                .navigationBarTitle("Hello")
        }
}

показывает:

Image 1

Но при попытке создать стиль .inline для navBar представление ведет себя странно:

var body: some View {
        NavigationView {
            MapView(annotations: $annotations)
                .centerCoordinate(.init(latitude: 37.791293, longitude: -122.396324))
                .navigationBarTitle("Hello", displayMode: .inline)
                //.navigationBarColor(.parqGreen)
        }
}

Image 2

И при добавлении цвет:

Image 3

Есть идеи, почему это происходит? Это что-то в инфраструктуре MapBox?

Обновление: добавлен MapView:

struct MapView: UIViewRepresentable {

    @Binding var annotations: [MGLPointAnnotation]

    private let mapView: MGLMapView = MGLMapView(frame: .zero, styleURL: MGLStyle.streetsStyleURL)

    func makeUIView(context: UIViewRepresentableContext<MapView>) -> MGLMapView {
        mapView.logoView.isHidden = true
        mapView.attributionButton.isHidden = true
        mapView.zoomLevel = 13

        if let styleURL = URL(string: "mapbox://styles/morreke/cjkz2y4bq0kb12smmigszo70w") {
            mapView.styleURL = styleURL
        }
        return mapView
    }

    func updateUIView(_ uiView: MGLMapView, context: UIViewRepresentableContext<MapView>) {
        updateAnnotations()
    }

    private func updateAnnotations() {
        if let currentAnnotations = mapView.annotations {
            mapView.removeAnnotations(currentAnnotations)
        }
        mapView.addAnnotations(annotations)
    }

    func centerCoordinate(_ centerCoordinate: CLLocationCoordinate2D) -> MapView {
        mapView.centerCoordinate = centerCoordinate
        return self
    }
}

Обновление 2: Даже самая простая реализация имеет тот же результат

struct MapView: UIViewRepresentable {

    private let mapView: MGLMapView = MGLMapView()

    func makeUIView(context: UIViewRepresentableContext<MapView>) -> MGLMapView {

        return mapView
    }

    func updateUIView(_ uiView: MGLMapView, context: UIViewRepresentableContext<MapView>) {
    }
}

1 Ответ

0 голосов
/ 03 мая 2020

Обновление Xcode с 11.3.1 до 11.4.1 сделало свое дело.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...