swift - how can I use constraints on a group of elements in storyboard in ios? -


in uistoryboard have following situation:

enter image description here

a uiviewcontroller 2 elements - button , label. text on each component fetched localized.strings, has different length each time user chooses different language. in code have:

mybutton.settitle("textonbutton".localized(), for: .normal) mybutton.sizetofit() txtlabel.text = "txt".localized() 

how should attach constraints 2 elements - when grouped - in center? example:

this not in middle:

enter image description here

this in middle:

enter image description here

if 1 element, attach constraint midx , that's all, situation when there 2 elements? can - somehow - attach constraints group of elements?

you can achieve of called stack view. in storyboard select both labels , click following button:
stackviewbutton

in hierarchy notice both labels got wrapped inside stack view. have add horizontally in containerand vertically in containerconstraints stack view. can add spacing between 2 labels in attribute inspector when stack view selected.
result:
final result


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -