Dheeraj Chahar
Dheeraj Chahar

Reputation: 116

How to take screen shot in iOS device programmatically for SOS?

Using new API's like:

Using these I want to take photo in any format and need to send.

Upvotes: 0

Views: 837

Answers (1)

Rahul Patel
Rahul Patel

Reputation: 1832

try this

UIView *screenshotView = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:NO];
UIImage *snapshotImage = [self imageFromView:screenshotView];

- (UIImage *)imageFromView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return img;
}

Upvotes: 0

Related Questions