Get Position Center from UIButton

I need to get the UIButton start center position

eg

this gives the size of UIButton

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

How to get the rank of the center of the origin of UIButton coordinates? any help is appreciated

+4
source share
2 answers
  CGPoint centerPoint = [button center]; 
+8
source
 NSLog(@"%f",button.frame.origin.x); NSLog(@"%f",button.frame.origin.y); 

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

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

and you can get the center of your button, for example:

 CGPoint center = [button center]; 
+2
source

Source: https://habr.com/ru/post/1502502/


All Articles