如何显示自定义呼叫视图单击此标志,如此给定的图像



我是iOS开发人员。我正在尝试显示自定义呼叫视图单击(PIN)。此呼叫视图包含两个按钮。我已经尝试使用以下给定代码显示自定义标注视图。

       func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!) {
    var calloutSize:CGSize = CGSizeMake(200.0, 110.0)
    confirm = MKAnnotationView(frame: CGRect(x: -calloutSize.width/2, y: -calloutSize.height - 10, width: calloutSize.width, height:calloutSize.height))
    confirm!.backgroundColor = UIColor(white: 0.9, alpha: 1)
    confirm!.alpha = 0.7

    let button_Yes = UIButton(frame: CGRectMake(0, 0, 200, 54))
    button_Yes.backgroundColor = UIColor.purpleColor()
    button_Yes.setTitle("See listing detail", forState: UIControlState.Normal)
    button_Yes.addTarget(self, action:Selector( "checkout:"), forControlEvents: UIControlEvents.TouchUpInside)
    button_Yes.userInteractionEnabled = true
    button_Yes.tag = 1
    confirm!.addSubview(button_Yes)
    let button_No = UIButton(frame: CGRectMake(0,calloutSize.height / 2, 200, 54))
    button_No.backgroundColor = UIColor.purpleColor()
    button_No.setTitle("Get directions", forState: UIControlState.Normal)
    button_No.addTarget(self, action:Selector("checkin:"), forControlEvents: UIControlEvents.TouchUpInside)
    button_No.userInteractionEnabled = true
    button_No.tag = 2
    confirm!.addSubview(button_No)
    view.addSubview(confirm!)

}

func mapView(mapView: MKMapView!, didDeselectAnnotationView view: MKAnnotationView!) {
    confirm!.removeFromSuperview()
}

我已经嵌入了图像URL,我想喜欢此标注

为此,您需要创建MKAnnotationView和XIB的子类使用此功能您可以在

中返回自定义视图以进行注释
mapView(_:viewForAnnotation:)

这是最好的例子:https://www.cocoacontrols.com/controls/gikanimatedCallouthttps://www.cocoacontrols.com/controls/multirowcalloutannotationview

最新更新