I have a UISlider
as part of a view that is loaded into a UIScrollView
with paging enabled. I\'ve noticed an unexpected behavior. If the user tries
most upvoted comment code in Swift 3 :)
import Foundation
class UISliderForScrollView:UISlider {
var thumbRect:CGRect {
let trackRect = self.trackRect(forBounds: bounds)
return thumbRect(forBounds: bounds, trackRect: trackRect, value: value)
}
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if thumbRect.contains(point) {
return super.hitTest(point, with: event)
} else {
return superview?.hitTest(point, with: event)
}
}
}