0

How to take screenshot of a selected frame in UIView and set it as a UIImage?

I Also tried this

UIGraphicsBeginImageContext(CGSizeMake(width,height));
CGContextRef context = UIGraphicsGetCurrentContext();
[imageview.layer renderInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Arunkumar
  • 29
  • 6

1 Answers1

0

you can do like this

CGRect rect = [captureView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:context];   
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext()
Purva
  • 1,291
  • 2
  • 15
  • 30