- (IBAction)exportMapViewImage:(id)sender { //export image of mapView UIGraphicsBeginImageContext(self.mapView.frame.size); [self.mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //save image to photo album UIImageWriteToSavedPhotosAlbum(screenshot,self,@selector(image:didFinishSavingWithError:contextInfo:),nil); } - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { // Was there an error? if (error != NULL) { // Show error message... UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@Error message:[error localizedDescription] delegate:nil cancelButtonTitle:@OK otherButtonTitles:nil]; [alert show]; [alert release]; } else // No errors { // Show message image successfully saved UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@Image Saved message:@Image saved to photo album successfully! delegate:nil cancelButtonTitle:@OK otherButtonTitles:nil]; [alert show]; [alert release]; } }
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), NO);
UIGraphicsBeginImageContextWithOptions(self.mapView.frame.size, NO, 0.0f);
UIGraphicsBeginImageContextWithOptions(self.mapView.frame.size, NO, 0.0f); CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), NO); [self.mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //save image to photo album UIImageWriteToSavedPhotosAlbum(screenshot,self,@selector(image:didFinishSavingWithError:contextInfo:),nil);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.