-1

A view at the bottom of a view controller with the following constraint:

leading - 0

trailing - 0

bottom - 0

aspect ratio - 7:1

it looks good on small screen sizes, but on larger screen the view looks too small. What is the best way to increase the aspect ratio according to what screen is using the application

Ali Alebrahim
  • 617
  • 1
  • 9
  • 25
  • your question don't make sense. if your aspect ratio 7:1, the size will increase accordingly to the screen size. – jo3birdtalk Jul 24 '16 at 12:50
  • Why don't you put constraint that rely to the size of the screen. Instead of having an aspect ratio of 7:1, replace it with a constraint "proportional to height" and "proportional to width" – RomOne Jul 25 '16 at 04:41
  • i don't know how to do it. could you provide any help? – Ali Alebrahim Jul 25 '16 at 05:06

1 Answers1

4

Instead of having aspect ratio set, use proportional height and proportional width. To do so:

1- Select your view and set its height equal to the height of its superview Add height constraint

2- Click Edit and then change "proportional" to whatever you want:

enter image description here Now you have a view that will be proportional to its superview height. Do the same for its width if you need it.

To be more precise, you can play with the priority of the constraint. For instance keep your ratio constraint and set its priority to 999. Then change both proportional constraints (those we just add) constant to ">=" instead of "=". Then try different values of multiplier to see how the view react. By doing this you might need a maximum height/width constraint as well (as the view won't know in certain cases which size to choose).

RomOne
  • 2,065
  • 17
  • 29