UIButton Changing Position

casillas picture casillas · May 6, 2013 · Viewed 13k times · Source

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.

enter image description here

Now I would like to change the position of it accordingly. Is it possible? If yes, please let me know how, since I am trying to change the position of my button in the following code, but it does not work in the header file.

@property (nonatomic, strong) IBOutlet UIButton *mybuttonOutlet;

In the implementation file:

-(void)viewDidLoad {


    screenSizeHeight=[UIScreen mainScreen].bounds.size.height;


if(screenSizeHeight==568)

    mybuttonOutlet.frame= CGRect(38, 464 ,157,25);


if(screenSizeHeight==480)

    mybuttonOutlet.frame= CGRect(38, 364 ,157,25);

}

Answer

Retterdesdialogs picture Retterdesdialogs · May 6, 2013

Remove Use Autolayout from the button in IB or storyboard.