Search code examples
iosxcodeuibuttoniphone-5

Button position changing accordingly - customize for iPhone 5


I am working on my app to customize for iphone 5. I have button and want it to customize accordingly.

I have placed my button by drag and drop and placed where it should be. Now I would like to change the place accordingly.

It is possible? If yes, please let me know how. Since I am trying the change the position of my button in the following but it does not work in header file

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

in implementation file:

- (void)viewDidLoad {

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


if(screenSizeHeight==568)

    mybuttonOutlet.frame= CGRect(40, 80,125,150);


if(screenSizeHeight==480)

    mybuttonOutlet.frame= CGRect(40, 80,85,150);

}

Solution

  • You shouldn't need any code just set the springs and struts correctly, attach the button to the bottom of the screen and not the top.

    enter image description here