How to get the X and Y position of a UI button iPhone
CGPoint position = myButton.frame.origin;
This works for any UIView.
The compiler is right (as it's prone to be): there is no method called imageRectForContentRect
. There is, however, imageRectForContentRect:
which takes a CGRect as its argument. You don't have to use it to get the position.
Use
myButton.frame
Specifically for position, use myButton.frame.origin.x and myButton.frame.origin.y. That would be the top left corner. This is the easiest solution for finding a button's position.