不知怎的,我的rightCalloutAccessoryView不可见,这就是它的样子:
按钮位于右侧,但它是白色的。我该如何改变它的颜色?据我所知,它通常是蓝色的。
这是我的代码:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if !(annotation is CustomPointAnnotation) {
return nil
}
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if anView == nil {
anView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView!.canShowCallout = true
anView!.calloutOffset = CGPoint(x: -5, y: 5)
anView!.rightCalloutAccessoryView = UIButton.buttonWithType(UIButtonType.InfoLight) as! UIView
}
else {
anView!.annotation = annotation
}
//Set annotation-specific properties **AFTER**
//the view is dequeued or created...
let cpa = annotation as! CustomPointAnnotation
anView!.image = UIImage(named:cpa.imageName)
return anView
}
答案 0 :(得分:0)
啊,我找到了答案。这就是我做到的。
var calloutButton = UIButton.buttonWithType(.DetailDisclosure) as! UIButton
calloutButton.setImage(UIImage(named: "arrow-right.png"), forState: UIControlState.Normal)
calloutButton.tintColor = UIColor(red: CGFloat(51/255.0), green: 51/255, blue: 51/255, alpha: 1)
我只需要调用按钮tintColor。