Ustawiam tablicę, która przechodzi przez wszystkie kolory tęczy. Właśnie teraz ręcznie wprowadziłem kolory w tablicy, ale jest ich zbyt wiele, aby ręcznie wpisywać ... od tej pory używam od 0,25 do 0,5 do 0,75 do 1 i tak dalej, aż przejdę od czerwonego do zielonego do niebieskiego i z powrotem. (zobacz poniższy kod), w jaki sposób mogę automatycznie wygenerować kolory z więcej niż 0,25 -> 0,5 -> 0,75, ale może 0,05 -> 0,10 -> 0,15 -> 0,20 itd., ... oto moja tablica:Tablica kolorów tęczy iOS
rainbowColors = [[NSArray alloc] initWithObjects:
[UIColor colorWithRed:1 green:0 blue:0 alpha:1],
[UIColor colorWithRed:1 green:0.25 blue:0 alpha:1],
[UIColor colorWithRed:1 green:0.5 blue:0 alpha:1],
[UIColor colorWithRed:1 green:0.75 blue:0 alpha:1],
[UIColor colorWithRed:1 green:1 blue:0 alpha:1],
[UIColor colorWithRed:0.75 green:1 blue:0 alpha:1],
[UIColor colorWithRed:0.5 green:1 blue:0 alpha:1],
[UIColor colorWithRed:0.25 green:1 blue:0 alpha:1],
[UIColor colorWithRed:0 green:1 blue:0 alpha:1],
[UIColor colorWithRed:0 green:1 blue:0.25 alpha:1],
[UIColor colorWithRed:0 green:1 blue:0.5 alpha:1],
[UIColor colorWithRed:0 green:1 blue:0.75 alpha:1],
[UIColor colorWithRed:0 green:1 blue:1 alpha:1],
[UIColor colorWithRed:0 green:0.75 blue:1 alpha:1],
[UIColor colorWithRed:0 green:0.5 blue:1 alpha:1],
[UIColor colorWithRed:0 green:0.25 blue:1 alpha:1],
[UIColor colorWithRed:0 green:0 blue:1 alpha:1],
[UIColor colorWithRed:0.25 green:0 blue:1 alpha:1],
[UIColor colorWithRed:0.5 green:0 blue:1 alpha:1],
[UIColor colorWithRed:0.75 green:0 blue:1 alpha:1],
[UIColor colorWithRed:1 green:0 blue:1 alpha:1],
[UIColor colorWithRed:1 green:0 blue:0.75 alpha:1],
[UIColor colorWithRed:1 green:0 blue:0.5 alpha:1],
[UIColor colorWithRed:1 green:0 blue:0.25 alpha:1],nil];
Proste, czyste i daje prawidłowe wyniki. Świetna odpowiedź. –
Cudownie! Dziękuję Ci!! –
Tyle magicznej paczki razem ... to zrobiło mój dzień, DZIĘKUJĘ! –