How to get UIImageView program codes?

I want to get the coordinates of a UIImageView programmatically. How to do it?

For example, I have a square. I want to get the coordinates of all angles. How should I act?

NSLog("%f", ImageView.frame.origin.x); NSLog("%f", ImageView.frame.origin.y); 

I get the stupid coordinate of the square.

I have to say that the square (image) rotates and therefore I have to get its coordinates.

+6
iphone animation ipad uiimageview
source share
1 answer

Coordinates in coordinate space?

Each UIView has its own coordinate space. You can refer to the size of the view in your own coordinate space by requesting its bounds .

The size and position of the view in the parent view is called frame . In your example, you request the top left corner of the image in its coordinate space of the parent view.

If this is what you want to do, try the following:

 frame.origin.x frame.origin.y frame.size.width frame.size.height 

Adding them together, you can get any coordinate: for example, the x coordinate of the upper right will be

 frame.origin.x + frame.size.width 
+9
source share

All Articles