AppKit is not available in iOS, so I was looking for a replacement.
Specifically, I was looking for a replacement method for:
- (NSColor *)interpolatedColorAtLocation: (CGFloat)location
I need a way to define a gradient, and lookup a colour value based on an input location (float
).
If you actually need a gradient object (for drawing the gradient?), you can use the CG-level CGGradient "class".
As for interpolating the color at a specific location in the gradient all you need to know are the two surrounding colors (relative to your given location) and the interpolate between them (
t
would then be a location between0.0..1.0
relative to the two colors, not the entire gradient):Example use: