tags:

views:

39

answers:

1

Hello All,

How to Get the X and Y axis of UIImage, I have one images which are randomly changes it's position so how to get the image current x and y position so i can match with another image x and y position.I have to get the position of Image without any touch on screen. please suggest some solution.

Thank You.

A: 

You can get the frame of any view by accessing its frame property. Within that frame struct are a CGPoint origin and a CGSize size value. The origin is probably what you're looking for. Note that it is expressed in terms of relative position of the view within its superview.

For example, the following will print the origin coordinate of a view called imageView within its superview:

CGPoint origin = imageView.frame.origin;
NSLog(@"Current position: (%f, %f)", origin.x, origin.y);
Brad Larson