0

I am wondering if the following is possible and how to go about it.

I have an image (UIImageView) which is a png file with a transparent background. The image is all the same shade of grey (It is essentially a silhouette) and has 4 distinct segments.

Below the image I have a slider with 4 stops (inc start and end) - So when the user slides it 'snaps' so that the pointer is positioned directly beneath a 'segment' of the image.

What I would like to do is: If the slider is under segment 2 for example, the image will appear with a blue tint from a certain x position to another x position.

Patrick
  • 6,495
  • 6
  • 51
  • 78
  • I'm not sure I follow what you're asking here. Could you provide an example image of the effect you want to achieve? – Brad Larson Aug 28 '12 at 15:34
  • Why not use four images and simulate the snapping you're talking about? – Hyperbole Aug 28 '12 at 16:23
  • That would be too easy @Hyperbole :) I was hoping not to snap the colour overlay effect so it was a smooth transition over the 4 parts of the image – Patrick Aug 28 '12 at 18:31

1 Answers1

0

I think the best way to do this would be to monitor the UIControlEventValueChanged on a UISlider. You can set slider.minimumValue = 0; and slider.maximumValue = 4;.

Then in the action you set to UIControlEventValueChanged you can snap the slider to that location and change the tint. Ex:

- (void)valueChanged:(id)sender {
    if (value<0) {
         slider.value = 0;
         //Tint the uiimage
    }
    else if (value<1) {
         slider.value = 2;
         //Tint the uiimage
    }
}
James Paolantonio
  • 2,194
  • 1
  • 15
  • 32
  • Hey, I have the slider function working fine. It's the manipulating the image part I am working on. Also, this is the code I amusing to 'snap' my slider `-(IBAction)valueChanged:(UISlider*)sender { NSUInteger index = (NSUInteger)(slider.value + 0.5); // Round the number. [slider setValue:index animated:NO];` – Patrick Aug 28 '12 at 14:33
  • You can use Core Graphics. http://stackoverflow.com/questions/1117211/how-would-i-tint-an-image-programatically-on-the-iphone – James Paolantonio Aug 28 '12 at 14:42