Breaking News
Home / iOS / iOS Snippets / How to take screenshot in iOS using Code?

How to take screenshot in iOS using Code?

Ios Framework WeaklinkTaking screenshot of the an application view/screen from the app itself involves the use of GL API which is part of QuartzCore Framework as show below:

<!>Code

#import <QuartzCore/QuartzCore.h>

 
 
(UIImage*)captureView:(UIView *)view

{
CGRect rect = [[UIScreen mainScreen] bounds];

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[view.layer renderInContext:context];

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 

return img;

}
 
(void)saveScreenshotToPhotosAlbum:(UIView *)view

{
UIImageWriteToSavedPhotosAlbum([self captureView:view], nil, nil, nil);

}

[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger