0

How can I make a screenshot programmatically in iOS?

Cœur
  • 34,719
  • 24
  • 185
  • 251
cocos2dbeginner
  • 2,135
  • 1
  • 29
  • 56
  • 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
  • 162,909
  • 46
  • 287
  • 312