views:

1404

answers:

3

I understand how you can have a minimum track and maximum track image, and how it can be stretchable. However, for my needs, that might not be enough control.

I have a situation where on the left hand side (minimum track) I need to display two different colors, based on data. The left hand side actually represents two pieces of data, but yet there still exists only a single thumb between minimum and maximum.

so how can i do this???

Any sample code??

i actually want like this

photo link

On left hand side it is of grinish color but when it exceeds the thumb image it becomes red..

A: 
mahboudz
A: 

Hi,

I'm looking for something similar to raaz. I don't know if it's possible but I need a Slider with 2 thumbs ! I need a range of value and the slider will be perfect for this but as far as I search I found nothing...

Is there a solution ?

Thanks.

PS: This is the type of slider I want. Below the standard provided : http://img20.imageshack.us/img20/5286/slideru.jpg

My2ter
A: 

Put your image swapping code in your slider value-reading method, which is usually:

-(IBAction)sliderChanged:(id)sender; {}

Swap your custom green image with a custom red image whenever your slider value reaches some predefined value. See example below.

// Switches the -thumbImage between an ivar named highImage and lowImage 
// when the slider passes the halfway point  

if (sliderValue > 0.5) {
 [self updateSliderThumbWithImage:self.highImage];
} else {
 [self updateSliderThumbWithImage:self.lowImage];
}

define the slider image update method like this:

-(void)updateSliderThumbWithImage:(UIImage *)image;
{
    [self.slider setThumbImage:image forState:UIControlStateNormal];
    [self.slider setThumbImage:image forState:UIControlStateHighlighted];
}

// You have to set thumb images for both states  
// or your image will vanish when user slides it. 
// Not sure if you have to do the same with the track image, though.

Hope this helps somebody.

willc2