Search code examples
iosautolayoutxib

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?


Solution

  • 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.

    SpacerView

    Your Label