3

I have size of 4 inch and i have added 4 icons in 3 different rows of all equal size 60x60. I can have a proper view in iphone 4s,5,5s but not in iphone 6 and 6 plus. So how can i apply auto layout to it and make the icons look bigger and of same ratio in iphone 6 and 6 plus. Can this be made without any coding?

Like this enter image description here

This buttons should change its size in iphone 6 and 6 plus i.e. it should get bigger and proper aligned. Can it is possible without coding?

Parth Adroja
  • 13,198
  • 5
  • 37
  • 71
  • Click on the buttons. There is a square icon at the bottom right of the interface builder. Click on that and add aspect ratio 1:1, so the width = height. Then for making the width be relative to width of the Device, first make some calculations to see how big you want them. Then make add equal width for superview and the button and set the multiplier to whatever percentage you want (e.g .3 for 30%) – Gasim Apr 26 '15 at 07:20
  • @Gasim Do i need coding to do it or can be done using storyboard? – Parth Adroja Apr 26 '15 at 07:28
  • 1
    yes you can set this up completely in storyboard! – André Slotta Apr 26 '15 at 10:02
  • @AndreSlotta I dont know how to do it can u tell me the way to do it? – Parth Adroja Apr 26 '15 at 10:57
  • Read the [following](http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1). It will give you a good start – Gasim Apr 27 '15 at 10:28
  • Are you using collection view for that image? – Gasim Apr 27 '15 at 10:30
  • @Gasim No i am not using collection view. – Parth Adroja Apr 27 '15 at 14:41

1 Answers1

1

a simple example:

  1. drag a button from the object library to your viewcontroller's view in storyboard
  2. ctrl drag from your button to your view (drag to the left or the right) and choose center vertically in container
  3. ctrl drag from your button to your view (drag to the top or the bottom) and choose center horizontally in container
  4. ctrl drag FROM the button TO the button (yes, the same button) and choose aspect ratio
  5. in the size inspector check the button's aspect ratio constraint to have a multiplier of 1:1
  6. ctrl drag from your button to your view (drag to the left or the right) and choose equal widths
  7. in the size inspector check the button's equal width constraint to have a multiplier of 1:3 (or whatever value you like - 1:3 means that that the button's width is one third of the view's width)

that should be it. good luck! :)

André Slotta
  • 13,774
  • 2
  • 22
  • 34