我的malloc()
MKPinAnnotationView
收到leftCalloutAccessoryView
。
UIButton
我尝试自定义let pinView = MKPinAnnotationView()
pinView.pinTintColor = UIColor.blueColor()
pinView.canShowCallout = true
pinView.draggable = true
let button: UIButton = UIButton(type: UIButtonType.DetailDisclosure)
button.addTarget(self, action: "navigateUserFromCoordinates:", forControlEvents: UIControlEvents.TouchUpInside)
pinView.leftCalloutAccessoryView = button
return pinView
以显示我的图标但我无法确定如何执行此操作。
感谢。
答案 0 :(得分:1)
像这样:
let pinView = MKPinAnnotationView()
pinView.pinTintColor = .blueColor()
pinView.canShowCallout = true
pinView.draggable = true
let button = UIButton(type: .Custom)
button.setImage(UIImage(named: "yourImage"), forState: .Normal)
button.sizeToFit()
button.addTarget(self, action: "navigateUserFromCoordinates:", forControlEvents: .TouchUpInside)
pinView.leftCalloutAccessoryView = button
return pinView