For animating the annotations as its added, you can use this subclass of MKAnnotationView
class AnnotationView: MKAnnotationView {
override var annotation: MKAnnotation? {
didSet {
UIView.animate(withDuration: 0.5) { self.alpha = 1.0 }
}
}
override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
self.alpha = 0
}
override func prepareForReuse() {
super.prepareForReuse()
self.alpha = 0.0
}
}
Usage:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let view = mapView.dequeueReusableAnnotationView(withIdentifier: "annot") as? AnnotationView {
return view
}
return AnnotationView(annotation: annotation, reuseIdentifier: "annot")
}