Here is my previous thread, where I set image to annotation view pins
Swift - setting different images from array to annotation pins
Right now I encountered a problem with setting rounded corners on annotation view image.
cannot show callout with clipsToBounds enabled swift
appears that I have to choose between rounded corners or showing callout, I don't really get why these two can't come along. Is there any way to do that? Here is my viewForAnnotation function:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if !(annotation is RestaurantAnnotation) {
return nil
}
let reuseId = "restaurant"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView.canShowCallout = false
}
else {
anView.annotation = annotation
}
let restaurantAnnotation = annotation as RestaurantAnnotation
if (restaurantAnnotation.image != nil) {
anView.image = restaurantAnnotation.image!
anView.layer.masksToBounds = true
anView.layer.cornerRadius = (anView.frame.size.height)/10.0
}
else {
// Perhaps set some default image
}
return anView
}
Thanks in advance for any help!