How to handle taps on a custom callout view?

前端 未结 3 1786
Happy的楠姐
Happy的楠姐 2020-12-18 06:08

I am adding a callout view like this:

func mapView(mapView: MKMapView!,
        didSelectAnnotationView view: MKAnnotationView!) {
    let calloutView = UIVi         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 06:58

    Removing from annotation view swift 5

    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
            let hitView = super.hitTest(point, with: event)
            if (hitView != nil)
            {
                self.superview?.bringSubviewToFront(self)
            }
            return hitView
        }
        override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
            let rect = self.bounds;
            var isInside: Bool = rect.contains(point);
            if(!isInside)
            {
                for view in self.subviews
                {
                    isInside = view.frame.contains(point);
                    if isInside
                    {
                        break;
                    }
                }
            }
            return isInside;
        }
    

提交回复
热议问题