I work with auto-layout. Facing on an interesting issue. Fortunately, I overcame it for a while, but he needs to know how to best solve it.

Problem: As shown in the picture above, I have several buttons. Both of them should have been placed at the same width from the center of the UIView (the bold vertical line is the center point of view). Also I have to apply to the restriction so that the distance between the buttons is automatically adjusted. eg. the distance should be 25% of the width of the device. If my device width is 320, the distance between the buttons is 80 pixels and so on.
Solution (I tried): For the above problem, I tried to solve the problem. As shown in the figure, I added on the dummy view in UIView, the width of the dummy is equal to the interval between the two buttons. And then I applied the constraints to the dummy view. for example: 1. Horizontal centre of the UIView 2.Width equals to the UIView width with 0.25 as a multiplier
Question: The above solution works fine for me. But if in the future, if there are too many complex elements in my view, adding a dummy view might not be a good idea. So, is there any other clean way to do this?
source share