i need have x number of buttons in horizontal uistackview
, resides inside uiscrollview
. requirement buttons should evenly distributed in stack view, , number of buttons increases should reduce spacings make them fit width of screen, there's minimum spacing, when spacing's reduced , reached minimum spacing, buttons can extend beyond width of screen.
for example, when have 3 buttons want layout them like
|b1 b2 b3|
when have 5 buttons (assume can still fit width of screen less spacing):
|b1 b2 b3 b4 b5|
but when have 6 buttons , have keep minimum spacing, want stack view scroll inside container uiscrollview
.
looking @ doco of uistackview
, property spacing
is:
"the spacing property determines minimum spacing between arranged views."
so use minimum spacing requirement, first example have 3 items, guess need define stack view's size position, described in doco:
"define stack’s size along axis. in case, pin both edges of stack along it’s axis superview, defining stack view’s size in dimension. need pin 1 of other edges define stack view’s position. stack view sizes , positions content along axis fill defined space; however, unpinned edge moves freely, based on size of largest arranged view."
but problem is:
- how layout 3 buttons, 1 @ left edge, 1 in middle , 1 @ right edge?
- when have more items couldn't fit width of screen, how determine should not pin stack view's right edge right of superview, size can grow?
thanks!
Comments
Post a Comment