如何在swift中添加彩色边框气泡标注?

时间:2015-12-06 10:51:34

标签: ios swift mkmapview mkannotationview calloutview

我在标注中添加了一个右键,但现在我想在整个气泡/标注中添加彩色边框。假设我想要整个气泡带有彩色边框。  我想实现view?.detailCalloutAccessoryView?.layer.borderWidth = 5.0 view?.detailCalloutAccessoryView?.layer.borderColor = UIColor(red:51/255.0, green:153/255.0, blue:255/255.0, alpha: 1.0).CGColor 的东西,但它不起作用

类似的东西(我知道这里他们只是一个红色的视图)但内部是白色的,但带有彩色边框

enter image description here

 //MARK: this is for adding info button to pins on map 1/2
    func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
        var view = mapView.dequeueReusableAnnotationViewWithIdentifier("AnnotationView Id")

        if view == nil{
            view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "AnnotationView Id")
            view!.canShowCallout = true
        } else {
            view!.annotation = annotation
        }
        //is this right?
        view?.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure)
        view?.rightCalloutAccessoryView?.layer.borderColor = UIColor(red:222/255.0, green:225/255.0, blue:227/255.0, alpha: 1.0).CGColor

        return view
    }

    //MARK: this is for adding info button to pins on map 2/2
    func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

        if (control as? UIButton)?.buttonType == UIButtonType.DetailDisclosure {

            let annotation = view.annotation as! MyMKPA
            self.userToPass = annotation.pointAnnotationPFUser
            mapView.deselectAnnotation(view.annotation, animated: false)
            performSegueWithIdentifier("fromMapToDetail", sender: view) 
        }
    }

0 个答案:

没有答案