Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set View height as percentage of the screen height in Storyboards with XCode 7

I need to design the view like below image and I have tried with fixed heights and also tried compact width and regular height and regular width and compact height but those scenarios did not worked for me.

How can i set View height as percentage of the screen height in Storyboards?

I'm using Xcode 7

enter image description here

like image 622
iReddy Avatar asked Mar 16 '16 17:03

iReddy


2 Answers

Basically you need to act on the multiplier property of an height equal constraint. To do that while pressing CTRL, drag from the view to its superview and select equal heights constraint, later edit this constraint in Size Inspector by setting its multiplier the desired value can be expressed also as 1:25, 1/25, 0,025. If it working on the contrary just reverse items as in the picture.
enter image description here

like image 111
Andrea Avatar answered Sep 21 '22 04:09

Andrea


You can simply set the height of each one as a ratio of the UI height, 15% height would be;

.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height * 0.15)
like image 39
Nurudeen Amedu Avatar answered Sep 17 '22 04:09

Nurudeen Amedu