1

I am using dynamic segmented control. Whenever user adds new decks, the title is showing up in the segmented control.

enter image description here

However, I need a horizontally scrollable segmented controller that might have different title width depending on the text (title) size.

  • You will need to use a collection view not a segmented control. Segemented controls won't scroll the way you want. – flanker Mar 27 '21 at 18:56
  • it works actually. I added the solution here. thanks – Evrim Demir Mar 27 '21 at 19:23
  • I guess that depends on how you define 'work' - see the comments by the OP below, IMO this is a very poor UI/UX and I wouldn't put it in any of my apps, especially when UIKit provides a far better native solution to do this. – flanker Mar 28 '21 at 01:39

1 Answers1

1

this helped me to achieve it. iOS 13 Segmented Control: Remove swipe gesture to select segment

I added my segmented controller inside of scroll view. Then changed my segmented controller class to the following;

class NoSwipeSegmentedControl: UISegmentedControl {

    override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
}