Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change size of UIButton

I'm trying to resize a UIButton in my iPhone app. I have a UIButton synthesized and when I call the following code, it moves on the screen, but the width & height of the button never change.

button.frame.size = CGRectMake(104, 68, 158, 70);

For example, when I change the height (70) to 40, the height of the button does not change. If I change the x or y, however, it will move on the screen.

Any ideas?

like image 715
Adam Avatar asked Mar 27 '10 22:03

Adam


1 Answers

To change the size of the Button you do:

[button setFrame:CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)];

example

[button setFrame:CGRectMake(173, 269, 130, 44)];

Make sure that the check box "Use Autolayout" is not set in the Xib file or Storyboard. If the option is set then the command does not work.

like image 54
Thorsten Niehues Avatar answered Oct 20 '22 00:10

Thorsten Niehues