I have made a UISlider
work just like the "slide to unlock" slider.
What I need to do is determine the point at which lifting your finger off is classed as touchUpOUTSIDE
and not touchUpINSIDE
. This is the point where you slide your finger past the end of the slider too far.
I guess it's the same as with a UIButton
, you can press the button then slide your finger off the button and depending how far you go, it can still be classed as touchUpInside
.
If possible, i'd like to mark the target area with a circle.
Once i've managed to find where this point is, is it possible to change it? So I could have a bigger target area?
I really don't know where to start with this. Thanks
It's taken me a few hours, but i've managed to sort this. I've done a lot of testing overriding touchesMoved, touchesEnded and sendAction:action:target:event and it seems that any touch within 70px of the frame classes as a touch INSIDE. So for a UISlider that's 292x52 any touch from x:-70 to x:362 or y:-70 to 122 will count as an inside touch, even though it's outside the frame.
I have come up with this code that will override a custom class to allow a bigger area of 100px around the frame to count as an inside touch:
With a little bit more tweaking I should be able to use it for the opposite also. (Using a closer touch as an outside touch).
According to the docs, the
UIControlEventTouchUpOutside
event is triggered when the finger is outside the bounds of the control. If you're trying to change that area, the slider will scale with it. Why not just tie the action forUIControlEventTouchUpOutside
to the same asUIControlEventTouchUpInside
?