How to align two buttons equidistance from the centre of the UIView

后端 未结 3 1937
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 07:29

I am working with auto layout . Facing on interesting issue . Fortunately overcame from it for the time but need to know the best way to solve it .

3条回答
  •  佛祖请我去吃肉
    2021-02-06 08:22

    You can do this in the storyboard (or xib) by using constraints to the right edge of the screen -- the value of the right edge is the same as the width of the screen, so you can use that for calculations. For the left button you want its trailing edge to equal the superview's right edge times 0.375 (0.5 minus .125 which is half of your 25% requirement). the right button would have its leading edge equal to right edge of superview times 0.625 (.5 + .125).

    The constraints look like this,

    enter image description here

    enter image description here

提交回复
热议问题