Rohan Sanap
Rohan Sanap

Reputation: 2862

Get specific corner co-ordinates of UIView/UIImageView irrespective of its rotation

I have a simple UIImageView of in my screen as follow:

To get the co-ordinates of highlighted corner of this UIImageView, I use simple formula:

CGPointMake(CGRectGetMaxX(imageView.frame), CGRectGetMaxY(imageView.frame))

Now I rotate this imageView and it looks as follows:

After this rotation, how can I get the co-ordinates of this highlighted point? Because after rotation, the previous code is not applicable.

Upvotes: 2

Views: 348

Answers (1)

Edder Núñez
Edder Núñez

Reputation: 165

You can consult the next link topic: Transformation of Coordinates Involving Rotation

https://www.math10.com/en/geometry/analytic-geometry/geometry1/coordinates-transformation.html

It only applies cos and sin functions to calculate (x,y) in the new rotated coordinate system. All you need is the rotation angle.

Upvotes: 1

Related Questions