I have following layout. The yellow view is a buttonsContainerView
which acts as a container for 3 equal width buttons that it holds. All the three buttons are subview of yellow coloured buttonsContainerView
. All the constraint that I have given are basic and visible and understandable in screenshot but still I will explain them below.
buttonsContainerView
- (yellow view) Pinned to top ofviewController
'sview
'ssafeArea
with an inset of20
. It's leading and trailing are pinned toview
's leading and trailing.Button 1
- Top, bottom and leading pinned tobuttonContainerView
's top, bottom and leading respectively. Trailing pinned toButton 2
's leading.Button 2
- Top, bottom pinned tobuttonsContainerView
's top and bottom respectively. Leading pinned toButton 1
trailing. Trailing pinned toButton 3
's leading.Button 3
- Top, bottom and trailing pinned tobuttonsContainerView
's top, bottom and trailing respectively. Leading pinned toButton 2
's trailing.- Equal widths - All three buttons are given equal width constraint with each other.
Problem - Any of these three buttons may get a longer title dynamically and according to various phone screen sizes it may not accommodate in single line. I want my buttonsContainerView
's height to resize its height according to the tallest button, i.e., button with longest title hence greater height (In screenshot - Button 2
, the centre button). In my case, buttonsContainerView
is taking up height of smallest button (Button 1 and Button 2 in screenshot). How do I achieve this using AutoLayouts?