2

I have been trying to take screenshot on MKMapView on which i am drawing user location draw a path using the BreadCrumbs classes CrumbPath and CrumbPathView overlay and overlay view classes.

Here is the code i am using to get the screen Shot:

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
    UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, [UIScreen mainScreen].scale);

else
    UIGraphicsBeginImageContext(self.view.frame.size);

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIImage * croppedImage = [Utils cropImage:viewImage withFrame:_map.frame];    
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage, nil, nil, nil);

ScreenShot i am trying to get Should look like this:

enter image description here

But the ScreenShot i get looks like this:

enter image description here

Here you can notice the Blue line (User Location Path) is not there in the ScreenShot.

Can anyone please help me suggest whats the solution or what am i doing wrong here?

Thanks Everyone.

4

1 回答 1

1

使用这个我的自定义方法它返回当前视图的图像..

- (UIImage *)captureView {

   //hide controls if needed
    CGRect rect = [self.view bounds];

    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:context];   
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;

}
于 2012-12-05T06:31:48.127 回答