i am creating a simple bar with a CAGradient layer. i have 6 colors that i want to be spread equally on the layer.
NSMutableArray *colors = [NSArray arrayWithObjects:
(id)[[UIColor colorWithRed:0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:.95] CGColor],
(id)[[UIColor colorWithRed:204.0/255.0 green:153.0/255.0 blue:0/255.0 alpha:.95]CGColor],
(id)[ [UIColor colorWithRed:204.0/255.0 green:102.0/255.0 blue:51.0/255.0 alpha:.95]CGColor],
(id)[ [UIColor colorWithRed:204.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:.95]CGColor],
(id)[ [UIColor blackColor]CGColor],nil];
NSMutableArray *locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithInt:0.14],
[NSNumber numberWithInt:0.28],
[NSNumber numberWithInt:0.42],
[NSNumber numberWithInt:0.56],
[NSNumber numberWithInt:0.70],
[NSNumber numberWithInt:0.84],
[NSNumber numberWithInt:1.0],nil];
and implement them with :
gradientLayer_.colors =colors;
gradientLayer_.locations=locations;
But I am getting a totally black bar. when i remove the locations i see the gradient perfectly but it is not divided well.
I feel that i don’t understand the locations well.
any help ?
[NSNumber numberWithInt:]on several of the stop location definitions. Use[NSNumber numberWithFloat:].