for a MKMapView : UIView
how could i convert the content of the mkmapview to a uiimage?
although from the mkmapview the end goal (or primary main objective, if you know what i mean) is a NSData var which I can 开发者_StackOverflowthen attach to an email with mimeType "image/png"
kinda of grabbing a screenshot of whatever the MKMapview is showing at any given moment
putting that on a (UIImage)mapImage
NSData *imageData= UIImagePNGRepresentation(mapImage);
any tips?
thanks in advance
Why not try something like this (untested)?
UIGraphicsBeginImageContext(mapView.frame.size);
[mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *mapData = UIImagePNGRepresentation(mapImage);
[mapData writeToFile:[self myFilePath:@"yourMap.png"] atomically:YES];
精彩评论