HomeiOS DevelopmentiOS 26 MapKit customized Annotation bug

iOS 26 MapKit customized Annotation bug


In iOS 26 i’ve a problem with mapKit.
i created a customized annotation utilizing “MKMarkerAnnotationView”, it really works high-quality with present secure iOS variations (15 to 18) however with iOS 26 the default annotation is displayed behind my annotation. i checked the Xcode UI inspector and there is a new subview within the “MKMarkerAnnotationView” known as “MKMarkerBalloonView” and it is the one displayed.

To be clear, the problem is when operating the app on iOS 26, even when i construct with iOS 18.x i nonetheless have the issue on units operating iOS 26.

i additionally tried opting out of the liquid Glass by including UIDesignRequiresCompatibility within the information.plist nevertheless it change nothing.

here is the “MKMarkerAnnotationView

    
    static let reuseId = "AnnotationMarkerView"
    
    non-public lazy var annotationView: UIView = {
        let hostController = UIHostingController(rootView: AnnotationView())
        let view: UIView = hostController.view
        view.translatesAutoresizingMaskIntoConstraints = false
        view.backgroundColor = .clear
        view.accessibilityElementsHidden = true
        return view
    }()
    
    init(annotation: MKAnnotation, reuseIdentifier: String?) {
        tremendous.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        
        self.setupUI()
        
        self.displayPriority = .required
        self.collisionMode = .circle
        
        self.titleVisibility = .hidden
        self.subtitleVisibility = .hidden
        self.markerTintColor = .clear
        self.glyphTintColor = .clear
        self.glyphImage = nil
        self.selectedGlyphImage = nil
        self.glyphText = nil
    }
    
    required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been carried out") }
    
    non-public func setupUI() {
        self.backgroundColor = .clear
        self.addSubview(self.annotationView)
        self.annotationView.centerXAnchor.constraint(equalTo: self.centerXAnchor, fixed: 0).isActive = true
        self.annotationView.centerYAnchor.constraint(equalTo: self.centerYAnchor, fixed: -24).isActive = true

        self.bounds = .init(origin: .zero, dimension: .init(width: 0, top: 0))
    }
}

and the MapViewDelegate:

    
    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        
        guard let annotation = annotation as? Annotation else {
          return nil
        }
        
        let annotatonView = AnnotationMarkerView(annotation: annotation, reuseIdentifier: AnnotationMarkerView.reuseId)
        
        return annotatonView

      }
}

Hyperlink to a demo venture.

problem on iOS 26:

iOS 26 MapKit Annotation issue

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments