I'm trying to draw a marker on an image (MKSnapshot) with a title, but the title is not showing up.
Does anyone has any idea why this would be the case?
let annotation = MKPointAnnotation()
annotation.coordinate = location
annotation.title = "TitleTest"
let pinView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "test")
pinView.titleVisibility = MKFeatureVisibility.visible
pinView.dragState = .none
pinView.animatesWhenAdded = false
pinView.canShowCallout = false
pinView.titleVisibility = .visible
pinView.contentMode = .scaleAspectFit
pinView.bounds = CGRect(x: 0, y: 0, width: 40, height: 40)
if rect!.contains(point) {
let pinCenterOffset = pinView.centerOffset
point.x -= pinView.bounds.size.width / 2
point.y -= pinView.bounds.size.height / 2
point.x += pinCenterOffset.x
point.y += pinCenterOffset.y
}
pinView.drawHierarchy(in: CGRect(
x:point.x,
y:point.y,
width:pinView.bounds.width,
height:pinView.bounds.height),
afterScreenUpdates: true)
print("Draw a marker on iOS 11")
This is a screenshot of my UIImageView
with the marker, but without the title: