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
I wanted to post this as a comment, but my account has no rep so I had to post a whole answer. user762391's answer including the hitTest override works perfectly. I just want to add that instead of overriding hitTest, you could instead override pointInside:withEvent: like this (keeping the thumbRect method):
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent * _Nullable)event {
return CGRectContainsPoint([self thumbRect], point)
}
or in Swift:
var thumbRect: CGRect {
return thumbRectForBounds(bounds, trackRect: trackRectForBounds(bounds), value: value)
}
override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool {
return thumbRect.contains(point)
}