import UIKit /// Custom scrollView that can forces touch cancellation, even in `UIControl`s /// - Note: Make sure to set `canCancelContentTouches` to `true` class TouchCancellingScrollView: UIScrollView { /// Set to `false` to allow drags in`UIControls` var canCancelControlContentTouches: Bool = true /// Cancels all touches, even when touch is in a `UIControl`. /// Set `alwaysCancelsContentTouches` to `false` to not use this behaviour override func touchesShouldCancel(in view: UIView) -> Bool { if canCancelContentTouches && canCancelControlContentTouches && view is UIControl { return true } return super.touchesShouldCancel(in: view) } }