I'm trying to render an MKMapView
into an UIImage
, without showing it on the screen. I init the map:
let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
mapView.delegate = self
let region = MKCoordinateRegionMakeWithDistance(location.coordinate(), 1000, 1000)
mapView.setRegion(region, animated: false)
I also implemented the MKMapKitDelegate
's method mapViewDidFinishLoadingMap()
. This method never gets called, unless I add the map to the view hierarchy and make it visible. This means that setting its alpha
to 0, or isHidden
to true
doesn't work (the map doesn't get loaded in this case). Help?