Reputation: 1
Given a UIImageView, and a CGRect inside that UIImageView, how do I get a sub-UIImage of the UIImage displayed in the UIImageView that is a cut-out of the image matching the CGRect?
I’m struggling to get a solution for this problem when the size of the image and image view do not match, and the contentMode is any arbitrary built-in value.
When the size of the image and the imageView are exactly the same, then one can use CGImageCreateWithImageInRect()
with the CGRect to do this. But if they’re different, then how can I do this?
I already tried using UIGraphicsBeginImageContextWithOptions()
and renderInContext:
as described here, and it was off-course.
Upvotes: 0
Views: 14