iOS - Get framing of Visible part of UIImage from UIImageView
Asked Answered
F

1

6

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

Flit answered 29/3, 2014 at 5:50 Comment(3)
I thinks this Link will help you #11121314Estren
thanks for Reply. but i Checked this one its for zooming. I am finding the frame visible in UIImageView after applying Aspect Fill. Means From 100x160 if the visible area is 100x120 in UIImageView then it should return 100x120. and from where that image is Anchored. well we are able to get Anchor Point but finding solution for Rect(frame) visible in UIImageViewFlit
How did you solve this?Wife
U
2

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);
Urus answered 29/3, 2014 at 6:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.