当用户点击一个图钉时,MKAnnotationView 会出现,但它非常有限。我创建了一个自定义按钮,但是有没有办法自定义从 pin 出现的整个视图?这是我到目前为止所拥有的。
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "location")
annotationView.canShowCallout = true
let btn = UIButton(type: .Custom) as UIButton
btn.frame = CGRectMake(50, 60, 60, 50)
btn.setTitle("button", forState: .Normal)
btn.titleLabel?.textAlignment = NSTextAlignment.Center
btn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center
btn.layer.borderColor = UIColor.blueColor().CGColor
btn.layer.borderWidth = 0.5
btn.backgroundColor = UIColor.redColor()
annotationView.rightCalloutAccessoryView = btn
return annotationView
}