I have 3 buttons one below the other.The requirement is , all should be centrally aligned.Also the dynamic contents should fit in these 3 buttons.Please help me with this issue. I have only a vague understanding about content hugging, compression resistance and intrinsic content size.Thank you very much in advance.
Aligning 3 buttons with dynamic contents in objective C using Autolayout
162 views Asked by iOSManiac At
2
There are 2 answers
4
On
Embed all UIBUttons within a UIStackView and set the stackViews properties to you needs.
To get the idea, see this answer.
Note: UIStackView is only available under iOS >= 9.
For
iOS 9and later:Use
UIStackViewto embed all yourbuttonsand set thatstack viewin centre of theview. For dynamic content, setstackView'sheightConstraintgreater than equalrelation(>=).For
iOS 8and earlier:Just use
UIViewInstead ofUIStackView. Rest of the things will be same.