Fabio
Fabio

Reputation: 1973

Get position center from UIButton

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

Upvotes: 4

Views: 3433

Answers (2)

Magyar Miklós
Magyar Miklós

Reputation: 4272

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

No, this will not give you the size, it will give you the x and y position of your button, the button size is:

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

and you can get the center of your button like:

CGPoint center = [button center];

Upvotes: 2

slysid
slysid

Reputation: 5498

 CGPoint centerPoint = [button center];

Upvotes: 8

Related Questions