How to divide UIView in to three even sized subviews horizontally in XCODE?

前端 未结 5 1474
你的背包
你的背包 2021-01-13 23:51

I Have to divide a UIView horizontally into three even sized subviews using Xcode. I tried to use constraints. I got the following result.

5条回答
  •  渐次进展
    2021-01-14 00:28

    Setting up constraint is technique that every used according to developer skills and usability. You will came with own one day. Here is the way i am using to handle situation like your.

    1)Create 3 views with equal width on storyboard.(You have already Done that) 2)Select all 3 Views together .

    • Add Leading Constraint(left)
    • Add Top Constraint.
    • Add Height/Bottom Constraint.(According to your needs/requirement)
    • Add Equal width Constraint.(MUST)

    Here is an image showing above step at once.

    Now Select Last View ie. 3rd View (You must select only Last view)

    • Add Trailing margin Constraint. (Right)

    You are good to go now.

    • Height/Bottom and Top constraint, you have to add according to your requirement.

    Like i said earlier, go with your convenience.

提交回复
热议问题