0

How can I make a screenshot programmatically in iOS?

Cœur
  • 37,241
  • 25
  • 195
  • 267
cocos2dbeginner
  • 2,185
  • 1
  • 31
  • 58
  • possible duplicate of [Take screenshot from code](http://stackoverflow.com/questions/3945800/take-screenshot-from-code) – Brad Larson Dec 31 '10 at 16:26
  • Possible duplicate of [How can I take screenshot from code on iOS?](https://stackoverflow.com/questions/3945800/how-can-i-take-screenshot-from-code-on-ios) – Cœur Apr 29 '19 at 14:48

1 Answers1

3

have fun

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *myScreenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337