cgcolor

What does CGColorGetComponents() return?

CGFloat* colors = CGColorGetComponents(hsbaColor.CGColor); Does this return a float, or an array of floats? It looks like the asterisk is shorthand for creating an array. Is that correct? When I call this function on the CGColor property of an HSB UIColor object does it convert the values to RGB? ...

Extracting rgb from UIColor

Seen this asked before but my example does not seem to work. const CGFloat *toCol = CGColorGetComponents([[UIColor greenColor] CGColor]); The array is empty from looking at it with GDB. Any hints? ...

Anomalous results getting color components of some UIColors

I'm trying to extract the rgb components of a UIColor in order to hand-build the pixels in a CGBitmapContext. The following sample code works fine for most of the UIColor constants but, confusingly, not all. To wit: CGColorRef color = [[UIColor yellowColor] CGColor]; const float* rgba = CGColorGetComponents(color); float r = rgba[0]; f...

How to convert colors from one color space to another?

Is there a Cocoa Touch way to convert colors from one color space to another? At the end of this code: UIColor *grey = [UIColor colorWithWhite: 0.5 alpha: 1.0]; CGColorRef greyRef = [grey CGColor]; int x = CGColorGetNumberOfComponents(greyRef); ...x is 2. The reason I need this is I'm trying to copy colors to a list of color compon...

How to draw a native looking statusitem background on a CALayer

Hi. Actually I want to draw the background of a selected NSStatusItem on the CALayer of my custom statusItemView. But since - (void)drawStatusBarBackgroundInRect:(NSRect)rect withHighlight:(BOOL)highlight does not work (?) on layers I've tried it to draw the color with the backgroundColor property. But converting the selectedMenuIte...

How to access the CGColor property of UIColor in CGContextSetFillColorWithColor?

CGContextSetFillColorWithColor(g, [UIColor greyColor].CGColor); I'm trying to follow O'Reilly's iPhone Game Development book on page 73 Chapter 3 but I'm running into a compile error that states error: request for member 'CGColor' in something not a structure or union According to the book's errata page this is an unconfirmed errata ...

Trying to get the CGColor value from a property causes crash

Hello, I'm trying to set a property like so - -interface: @property (readwrite, assign) CGColorRef otherBallColor; -someMethod: CGColorRef ballColor = [UIColor colorWithRed:255.0/256.0 green:165.0/256.0 blue:239.0/256.0 alpha:1.0].CGColor; [self setOtherBallColor:ballColor]; As soon as I try to access the value it crashes - -s...

Iphone development: UIColor / CGColor components comparison

Hello, I've got some internal codes for colors in my application, so I created a function that, given a color, returns the code. I'm having problems as it just doesn't work and return always "01" for every color else than the red, which returns the proper code. Has someone a clue about it? (NSString *)internalColorCode:(UIColor *)color ...