I'm trying to create a gradient texture in SpriteKit.
To do that, I have to use a CAGradientLayer
and render an image. My problem is with setting the colors.
From Apple's Documentation:
An array of
CGColorRef
objects defining the color of each gradient stop. Animatable.
So in code, I tried this:
gradient.colors = [NSArray arrayWithObjects:[UIColor redColor].CGColor, [UIColor whiteColor].CGColor, [UIColor blueColor].CGColor, nil];
This doesn't work, because CGColorRef
is not an object type and cannot be sent to type id
. My error is:
Incompatible pointer types sending
CGColorRef
(akastruct CGColor *
) to parameter of typeid
How can I create an array of CGColorRef
?
Just use an array literal and cast to
(id)
: