Search Your Question

If there are two views up and bottom, up-view is 60% of superview and 40% of superview respectively, then what to do with constraint?

Ans : 


Use of multiplier in constraint in iOS
Use of multiplier in constraint


We took 2 views - Orange and Green. 
We set orange view's top, leading, trailing constraint to main view as 0. 
Same, we set green view's bottom, leading, trailing constraint to main views as 0.

Now,
We select height constraint of orange view equal to main view's height. And set multiplier 0.6. It shows ratio of orange view's height to main view's height. We have set 0.6 = 60/100 . So orange view's height become 60% of main view's height.

Set multiplier of height constraint in size inspector
Set multiplier of height constraint in size inspector


Same we have done with green view and set multiplier 0.4 = 40/100 means 40%.

If you have any comment, question, or recommendation, feel free to post them in the comment section below!


No comments:

Post a Comment

Thanks