MKMapView UIGraphicsGetImageFromCurrentImageContext not working on retina display
Trying to capture image of a MKMapview was working on the iOS simulator, my iPod Touch and iPad, but not on my iPhone 4.
Turns out you have to use UIGraphicsBeginImageContextWithOptions…
This doesn’t work on the retina display:
(void)captureThumbnail:(id)theViewToCapture
{
UIGraphicsBeginImageContext(((UIView*)theViewToCapture).frame.size);
[((UIView*)theViewToCapture).layer renderInContext:UIGraphicsGetCurrentContext()];
theImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
This does work on the retina display:
(void)captureThumbnail:(id)theViewToCapture
{
UIGraphicsBeginImageContextWithOptions(((UIView*)theViewToCapture).frame.size, NO, 0.0);
[((UIView*)theViewToCapture).layer renderInContext:UIGraphicsGetCurrentContext()];
theImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}