iPhone UISlider with two thumbs/indicators?
Is anyone aware of a version of the iPhone UISl开发者_如何学Goider control with two thumbs? I need a control that will allow specifying a range of values. The UISlider API docs would imply this isn't possible with the standard control, so I was wondering if anyone had a solution for this (or had solved it themselves).
Here's a range slider I just cooked up
http://github.com/cmezak/CMRangeSlider
If you're still interested this is my implementation. I'm making it well documented so everyone could start using it with ease.
https://github.com/fcy/fancy-ios/tree/master/src/ui/range-slider
It works with iOS 5+
I had this problem too. The way I solved it was a bit of a hack but simpler for noobs like me!
I put two sliders on top of eachother. Made the track of one invisible using a transparent .png file. Then created a sliderReleased: method that I linked to the touch up inside event in interface builder that switches the userInteractionEnabled: state of each slider.
It means that you can only set one slider at a time and you have to touch one before you can set the other but for my purposes it does the job.
I linked both sliders' touch up inside to this method and set tags to 1 and 2 and linked the value changed event to individual methods like normal.
-(IBAction) onReleaseBP: (id) sender {
if ([sender tag]==1) {
[diastolicSld setUserInteractionEnabled:NO];
[systolicSld setUserInteractionEnabled:YES];
}
else {
[systolicSld setUserInteractionEnabled:NO];
[diastolicSld setUserInteractionEnabled:YES];
}
I made a range slider called DoubleSlide, it's not based on UISlider. But you can add images to make it look like one:
it's in here: https://github.com/richy486/RACommon
Here's my solution. One advantage versus other double-slider controls is that mine supports both setting up the control in code and in Interface Builder using IBDesignable/IBInspectable.
https://github.com/vermont42/JFADoubleSlider
I'm not aware of a current one (ie. still in active development) but you could probably derive one by looking at the source of BWToolkit ( http://brandonwalkin.com/bwtoolkit/ ).
There's an iTunes style slider implementation you could probably extend.
It's BSD licensed and the source is available from bitbucket.
精彩评论