iOS - Get framing of Visible part of UIImage from UIImageView

跟風遠走 提交于 2019-12-10 13:13:52

问题


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


回答1:


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);


来源:https://stackoverflow.com/questions/22727615/ios-get-framing-of-visible-part-of-uiimage-from-uiimageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!