4

I need get the position of the origin center of a UIButton

for example

this give the size of the UIButton

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

How get the center of origin frame of the UIButton?? any help is appreciated

4

2 回答 2

8
 CGPoint centerPoint = [button center];
于 2013-09-16T21:30:30.417 回答
2
NSLog(@"%f",button.frame.origin.x);
NSLog(@"%f",button.frame.origin.y);

不,这不会给你大小,它会给你按钮的 x 和 y 位置,按钮大小是:

NSLog(@"%f",button.frame.size.width);
NSLog(@"%f",button.frame.size.height);

你可以得到你的按钮的中心,比如:

CGPoint center = [button center];
于 2013-09-16T21:32:57.807 回答