How to add colored border bubble callout in swift?

2019-08-10 05:59发布

I added a right button to callout, but now I'd like add a colored border to the whole bubble/callout. let's say I want the whole bubble with a colored border. I thought to implement something as 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 but it doesn't work

something similar to this (I know that here they only aded a red view) but white inside, but with a colored border

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条回答
登录 后发表回答