I have the following for converting a UIView to UIImage
+(UIImage*) createUIImageFromView:(UIView *)view frame:(CGRect)frame;
{
if (UIGraphicsBeginImageContextWithOptions != NULL)
{
UIGraphicsBeginImageContextWithOptions(frame.size, NO, 2.0f);
}
else
{
UIGraphicsBeginImageContext(view.frame.size);
}
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
However, I can only select the size of the image but not where in the UIView should be converted to the image. For example, if I want to convert the rectangle CGRect(10,10,20,20) only but not the entire UIView, how do I do it?