TomThorpe / TTRangeSlider

A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.
MIT License
968 stars 204 forks source link

Animate sliders programmatically #101

Open grifas opened 4 years ago

grifas commented 4 years ago

Is there a way to animate selectedMinimum/selectedMaximum programmatically ?

I used:

UIView.animate(withDuration: 0.2) { [weak self] in
    self?.slider.selectedMaximum = value
    self?.layoutIfNeeded()
}

but no result :/

TomThorpe commented 4 years ago

Hey!

I’m not 100%, but I think this is possibly caused because the handles and lines within the control are mostly CALayers, not uiviews, so the uiview.animate method might not work as expected.

Do you get any better results if you use CATransaction with an animate duration? A bit like the - (void)animateHandle:(CALayer*)handle withSelection:(BOOL)selected { method within the implementation (this just animates the handles getting bigger as you select them, but its just an example of animation within the control)