Make the vertical space limit constant equal to the percentage of screen height

I want the constant value of the vertical distance constraint between my two areas to be a percentage of the height of the screen. Thus, the design looks approximately the same on all devices.

How to do this in a storyboard? Any famous tricks?

enter image description here

Perhaps there is some trick to achieve this with a crawl priority, compression resistance, or a second lower priority restriction?

+4
source share
3 answers

, , - . , .

- , make-.

+2

IBOutlet . , , . EX:

if(screenSize.height == 480)
{
  self.verticalspaceConstraints.constant = 100 ;//this is an example
}

//like this add your other conditions

, .

, .

+1

2 , .

1) UIView . , , . , .

2) , . NSLayoutConstraint , , .

0

Source: https://habr.com/ru/post/1650828/


All Articles