I have four points on UISlider
at 0, 1, 2 and 3. I want that when thumb position is from 0-1, it should come back to 0 but with elastic effect. Similar for 1-2, 2-3. This implementation will give me an edge in my application.
I have tried it with no elastic effect. But it does not look good.
Tell your slider to send an action on the “Touch Up Inside” event (UIControlEventTouchUpInside
). Hook the action up to this method:
- (IBAction)dragEndedWithSlider:(UISlider *)sender {
CGFloat roundedValue = roundf(sender.value);
[sender setValue:roundedValue animated:YES];
}
You can use truncf
instead of roundf
if that's what you really want.