views:

69

answers:

2

I have a button set up in IB. I have an IBOutlet set up and the onscreen object linked to it. Is there a way to programmatically change that buttons position and/or size? I know you can change the title and some things but I don't see how to change it's position or size.

Thank You.

+6  A: 

You can change the frame of the button (or any UIView).

CGRect frame = [button frame];
frame.origin.x += 100;  // change the location
frame.size.width += 100;  // change the size
[button setFrame:frame];
cobbal
Thank you sirs. I believe you've provided me the answer.
emachine
A: 

You simply create a new frame for it i.e. myButton.frame = CGRectMake(0,0,123,412); and it moves to that new frame. The order for CGRectMake is (origin x, origin y, width, height).

MishieMoo