views:

294

answers:

0

I have a UIImageView inside a UIScrollView. The UIImageView contains a UIViewContentModeScaleAspectFit content mode. I've also set the content size of the UIScrollview to the frame size (width, height) of my UIImageView and implemented a UIScrollview delegate method (viewForZoomingInScrollView:) to enable the zooming feature of my app.

Since the UIImage can now be zoomed-in/zoomed-out and scrolled, there is only now a portion of the image that is visible on the screen. I want that portion of image to be cropped out but I'm stuck in to getting the crop/visible rect of the UIImage.

I've also read one of the questions here Getting the visible rect of an UIScrollView’s content but it was of no help.

Somehow, I think I need to calculate some image offsets and image content size here. Has anyone here already solve/encountered this type of problem? If so, any examples/solutions posted here would be much appreciated.

Thanks in advance. :)