Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 更改rightCalloutAccessoryView的颜色_Ios_Swift_Mkmapview - Fatal编程技术网

Ios 更改rightCalloutAccessoryView的颜色

Ios 更改rightCalloutAccessoryView的颜色,ios,swift,mkmapview,Ios,Swift,Mkmapview,不知何故,我的rightCalloutAccessoryView不可见这就是它对我的外观: 按钮在右边,但它是白色的。我如何改变它的颜色?据我所知,它通常应该是蓝色的 这是我的代码: func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if !(annotation is CustomPointAnnotation) {

不知何故,我的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
}

啊,我找到了答案。我就是这样做的

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)
显然,我不得不把按钮按成彩色