Take a screenshot of just an image view
<p>I've an image view </p>

<pre><code>@property (strong, nonatomic) IBOutlet UIImageView *imageView;
</code></pre>

<p>which I want to screenshot. The code I have is taking the whole screen. I've looked at the other answers on here and still can't work it out as I don't want to designate a size, I just need the whole of the image view as a screenshot.</p>

<pre><code>- (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;
}
</code></pre>