Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create scrollable segment control (horizontally)

i am trying to create a scrollable segment control, more precisely i need a segment control that has 5-10 or more choices/buttons but because there will be no space for all that buttons i need it to be scrollable, i need to make the segment control itself to be scrollable. so far i have not see any tutorial for this in swift language or obj c.

enter image description here

i have tried to put segment control inside a view inside a scrollable view. i then change the width of both VIEW and Scrollable view into 1000. it is scrollable but only a little to the left and little to the right and the button width become very small. i have also try to change the width segmentcontrol.frame.size.width = 100 but it does not make any change. what did i miss??

this is the resultenter image description here

like image 527
Alan Avatar asked Sep 17 '26 13:09

Alan


1 Answers

Did you set the width on the contentSize property of the scrollview? Thats how it knows how much to scroll.

like image 180
Jeffrey Bergier Avatar answered Sep 20 '26 05:09

Jeffrey Bergier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!