swift - how can I use constraints on a group of elements in storyboard in ios? -
in uistoryboard have following situation:
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:
this in middle:
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:

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:




Comments
Post a Comment