ios - Function to return colour based on value passed -
i create function return colour based on value inserted it. ideally i'm looking have 3 different colours (e.g. red, green, blue) , range (e.g. 1 100), if example pass 80 function, return colour between green , blue (closer blue obviously). normally attempt write code before asking help, i'm not sure start one. anyone got suggestions? thanks. do mean 0 = red, 50 = green , 100 = blue ? if number = 40, it's mean has lot of red, of green, , none of blue? correct? i write in notepad, please recheck func getcolorfromnumber(number: int) -> uicolor { // case of color between red , green if number <= 50 { // color 1, base on 50 - number let rcolor1 = 0 let gcolor1 = cgfloat( double(50 - number) * 157 / 50 ) let bcolor1 = cgfloat( double(50 - number) * 29 / 50 ) // color 2, base on number let rcolor2 = cgfloat( double( number ) * 255 / 50 ) let gcolor2 = cgfloat( double( number ) * 148 / ...