does apple (or anyone else) have an example code of UISlider changing multiple colors with gradation? i've been at this problem of mine all day, and i just can't get it quite right.
i have a UISlider with values from 0 to 1.0. position 0 of the UISlider should return one color, 0.5 should be white, and 1.0 the other color, and of course they need to gradate while shifting slider positions...
please let me know if there is any sample code showing the math formula to do this.
right now i can get white at 0.0 and gradate to purple at 1.0... but my brain is turning to mush. although this problem at first seemed exciting and rewarding if successful, i've accepted the fact that code glory will have to wait and i totally need help.
i have a UISlider with values from 0 to 1.0. position 0 of the UISlider should return one color, 0.5 should be white, and 1.0 the other color, and of course they need to gradate while shifting slider positions...
please let me know if there is any sample code showing the math formula to do this.
right now i can get white at 0.0 and gradate to purple at 1.0... but my brain is turning to mush. although this problem at first seemed exciting and rewarding if successful, i've accepted the fact that code glory will have to wait and i totally need help.
Code:
float purplesRedValue = 105 / 255.0;
float purplesGreenValue = 0 / 255.0;
float purplesBlueValue = 122 / 255.0;
self.myView.backgroundColor = [UIColor colorWithRed: (1.0 - [sender value]) + ([sender value] * purplesRedValue)
green: (1.0 - [sender value]) + ([sender value] * purplesGreenValue)
blue: (1.0 - [sender value]) + ([sender value] * purplesBlueValue)
alpha:1.0];