TLDR: How to remove the swipe/pan gesture recognizer for UISegmentedControl on iOS 13?
Hi, on iOS 13, lots changed with UISegmentedControl. Mostly, the changes were
Using this code allows the segmented control to still be swiped UNLESS it's embedded in a UIScrollView. This is the smallest tradeoff in functionality in my opinion
final class NoSwipeSegmentedControl: UISegmentedControl {
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard type(of: gestureRecognizer).description() != "UIScrollViewPanGestureRecognizer" else {
return true
}
return super.gestureRecognizerShouldBegin(gestureRecognizer)
}
}