iOS - Get framing of Visible part of UIImage from

2019-06-20 04:55发布

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

1条回答
Root(大扎)
2楼-- · 2019-06-20 05:24

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);
查看更多
登录 后发表回答