I have a view with this hierarchy:
-UIView -UIImageView -UILabel
UIImageView contains a UIImage with a resizable/stretchable image created with resizableimagewithcapinsets.
When I take a screenshot everything looks fine:
https://i.stack.imgur.com/uA6Lg.png
But when I try to capture the view to an UIImage the result is like this:
https://i.stack.imgur.com/IzUyS.jpg
As you can see the bottom of the stretched image looks funny.
This is the code I use to capture the view to an UIImage:
- (UIImage *) imageWithView:(UIView *)view
{
[view setBackgroundColor:[UIColor whiteColor]];
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 2.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[view setBackgroundColor:[UIColor clearColor]];
return img;
}
Note: The app will only be used in @2x devices.