1

In my iOS application, i have added AVPlayerLayer as sublayer in myview.layer. For my requirement, i have to take the screenshot of this particular view. If i take the screenshot of this particular view, layer part is not included in the screenshot. And also i can't see this layer inside myview in Xcode preview option. Anyone please give your suggestion to accomplish this issue.

Ps: I have tried all the methods in this reference.

But all those methods exclude this CALayer.

EDITED CONTENT:

I need the screenshot of my UIView with the included layer(AVPlayerLayer). There are lot of options to take screenshot of UIView. But none of these option helps me. So i posted this question to resolve my issue.

Community
  • 1
  • 1
santhosh
  • 1,191
  • 4
  • 14
  • 28

1 Answers1

0

This solution from Tim should work perfectly (copied below for convenience).

#import "QuartzCore/QuartzCore.h" after you added the framework to your project. Then do:

UIGraphicsBeginImageContext(yourView.frame.size);
[[yourView layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// The result is *screenshot
Community
  • 1
  • 1
Quentin Hayot
  • 7,786
  • 6
  • 45
  • 62