I need some help with a function that I'd like to implement in my app. I have a view with an image view with content mode in Aspect Fit. When I get an image from my library I would like to crop an area with an adjustable rectangle creating a new image. I've looked for some exemple or online tutorial but I did not succeed. Can anyone help me with that? Here are the images from my View.
.
The simple solution is to just render the image view within a particular
CGRect
:The limitation of that approach is that if the image is a considerably higher resolution than the image view could render (as is often the case when we use “aspect scale fit”), you’ll lose this additional precision.
If you want to preserve the resolution, you should convert the
CGRect
to coordinates with the image, in this case, assuming “aspect scale fit” (namely, centered and scaled so the whole image is shown):Using this extension:
That yields:
If I understand your question correctly there are two parts to your question:
UIImage
Break your google query and search for solution based on the above questions separately.
Or probably take help or use something like this:
iOS-Image-Crop-View