Center an object between two objects with automatic layout

I post the calculator using Interface Builder, and I ran into some problems with the layout of the buttons.

I have 3 columns of numeric buttons, similar to most calculators, and I had no problems placing the left and right columns, since the Xcode auto-layout function anchored them at the correct distance from the edge of the window on the left and the operator buttons on the right; however, there was no automatic help to center the middle column of buttons between the two.

I can understand it well, but I really prefer everything to be perfectly aligned. Is there a way to center the button between two other user interface objects, for example? here is the layout image:

Calculator layout

+4
source share
1 answer

You can put all buttons in your own view. Place the view where you want the buttons. You can then align the left button to the left of the view, align the right buttons to the right of the view, and finally center the middle buttons. Then adjust your view, which you have made accordingly. I did something very similar. Hope this helps.

+6
source

All Articles