简体   繁体   中英

iOS Autolayout : Give top space equal to 1/5 of superview height

I want to set top space of my label to 1/5 of super view height. I know we can do this at runtime by changing the constant to 1/5 of super view. But I want to do this using XIB only. Is there any way to achieve this?

Indeed @EI Captain,

We need to use spacer view. @Mohammad, please have a look at constraints I have given to space view and label. it will definitely solve your issue.

Attaching screen shot for you! enjoy.

间隔视图

您的标签

A complicated way is to calculate the align to vertical center 在此处输入图片说明

128 = (600 - 20) * 0.2 so we set 0.6 to the multiplier

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM