Converting an NSColor to a CGColor
Here's an easy way to convert an NSColor to a CGColor:
- (CGColorRef)NSColorToCGColor:(NSColor *)color { NSInteger numberOfComponents = [color numberOfComponents]; CGFloat components[numberOfComponents]; CGColorSpaceRef colorSpace = [[color colorSpace] CGColorSpace]; [color getComponents:(CGFloat *)&components]; CGColorRef cgColor = CGColorCreate(colorSpace, components); return cgColor; }
Easy.











