Search code examples
iosobjective-ciphonescreen-positioning

ioS change button images to fill up the screen for iphone 3.5 inch and iphone 4 inch


I've just started writing iOs apps for work and I came across this problem which has to do with resizing my buttons on a screen to suit both the iPhone 3.5 inch and 4 inch. If you look at the screenshots below you will probably get the majority of what I am trying to solve.

Design of app for 3.5 inch screen

Design of app for 4 inch screen

So our designer has designed the layout whereby as you can see the colour buttons are supposed to fill the height of the screen for both iphone sets of devices, minus the height of the stautus bar and the navigation bar of the app.

I've had a look around a liitle bit about auto-resize, however I don't feel it is suitable for the requirements as you can see in the image.

Another approach that I thought about was in code, I would write an if statement, to determine if the person using the app was on the iphone 4 inch then load different images. However upon thinking about it more detail I would have to change the position for each of those buttons to ensure that the newly loaded images to prevent overlapping.

My question would be is there a way to change the position of the buttons in objective c to achieve what I want according to the screenshots?

Also it would be greatly appreciated if you can tell me if I am on the right track on the approach of my current problem.

Thanks heaps.


Solution

  • If you don't want to use AutoLayout, then I would advise turning it off in Interface Builder so you can control the frames manually. As for controlling the frames, make sure each of your views that you want to edit is accessible to your code (either its an IBOutlet or you manually instantiate it) and then adjust the myView.frame property. myView.frame is a CGRect, so you can edit it like this: myView.frame = CGRectMake(x, y, width, height).