Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Get framing of Visible part of UIImage from UIImageView

I am trying to make a transition like APP Tinder. Detail:

  1. In Screen One there is a Vertical Rectangular UIImaveView with contentMode = Aspect Fill, so it hides some portion of Image to adujust Aspect Ratio.

  2. In Screen Two (Detail Screen) the same image after transition has to to be passed, but the ImageView in Second screen is Square One.

    I want to make a Morphing kind of Transition in which User should think that the same ImageView from Screen One become square one in Second one without stretching the Image.So What should i do?

Currently i am trying to get Frame of UIImage that is in visible area of UIImageView so that I can do some Logical stuff to achieve this. but can anyone help me to Get the Frame of Visible Portion of UIImage.

EDIT

Please Find out the Attached Image for understanding enter image description here

like image 699
Mrug Avatar asked Mar 29 '14 05:03

Mrug


1 Answers

I think there's a little ambiguity in the question: a frame must be specified in a coordinate system. But I think you're looking for a rect relative to the original, unclipped image.

If that's right, then the rect can be computed as follows. Say the image is called image, and the image view is imageView. The size of the rect is the size of the image view:

imageView.bounds.size

And, since aspect fill will center the oversized dimension, it's origin is:

CGPointMake((image.size.width - imageView.bounds.size.width) / 2.0, 0.0);
like image 156
danh Avatar answered Oct 10 '22 00:10

danh