1

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) 
        }
    }
biggreentree
  • 1,633
  • 3
  • 20
  • 35
  • The [answer you took this from](http://stackoverflow.com/a/30824051/1271826) included a link to a project that does this. https://github.com/robertmryan/CustomMapViewAnnotationCalloutSwift Did you look at that? In answer to your question, there is no obvious way to doing this the preferred technique of using `detailCalloutAccessoryView`, so you have to do this yourself, methinks. It seems like there should be some `appearance` mechanism to set the background color of the bubble, but I haven't found it. – Rob Dec 07 '15 at 00:20
  • I'm still studying your project (I'm pretty new to iOS) but it seems clear that I can't simply subclass the callout and then call it via dot notation on `view!` or missing some annotation property in `viewForAnntation` right? – biggreentree Dec 07 '15 at 00:39
  • Sadly, I think you have to completely create your own callout to get this sort of look at feel. Personally, I'd recommend forgoing the complexity of all of this and just use `detailCalloutAccessoryView` and live with the limitation of the white background. – Rob Dec 07 '15 at 00:41

0 Answers0