自定义MAAnnotationView

iOS 高德SDK Swift自定义地图点标记样式

https://izumi.pub/iOS/iOS-amap-sdk/

 

2.点击无反应 

    override init?(annotation: MAAnnotation?, reuseIdentifier: String?) {
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        buildUI()
        customView.addTapGestureRecognizer { [weak self] in
            guard let self = self else { return }
            clickHandle?(self.shopModel)
        }
    }

要加上下边方法才有交互
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        var view = super.hitTest(point, with: event)
        if view == nil {
            if customView.bounds.contains(customView.convert(point, from: self)) {
                view = customView
            }
        }
        return view
    }

 

 

参考:

高德地图自定义AnnotationView没有交互效果的解决思路

https://blog.csdn.net/myfather103/article/details/126579643

 

posted on 2025-02-05 16:34  懂事长qingzZ  阅读(17)  评论(0编辑  收藏  举报