I want two buttons to have equal width and position themselves proportionally in all screens sizes from the top of the scree using autolayout?

后端 未结 6 1839
余生分开走
余生分开走 2021-01-27 01:43

Attaching the view i am planning to design. I would like to position the Buttons with respect to Superview and their Width and Height must increase proportionally to the Screen

6条回答
  •  感动是毒
    2021-01-27 02:28

    I've found the solution. Following are the constraints which i provided

    LEFT BUTTON:

    1.left leading constraint 2. top leading constraint

    RIGHT BUTTON

    1.right trailing constraint 2.top leading constraint

    Common for both

    1.Equal heights constraint 2.Equal Widths constraint

    To proportionally increase the height depending on the superview i added aspect ratio constraint from both buttons to the superview with button height 0.6 of superview height.

提交回复
热议问题