问题
const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]);
CGContextSetFillColor(context, color);
I have black background. While working this above code not sure whats wrong most of the colors work like redColor, purpleColor, greenColor, yellowColor
but whiteColor, grayColor does not work. when i use whiteColor screen looks empty.
回答1:
whiteColor
and greyColor
have colorspace different from redColor
, purpleColor
etc (I guess gray and rgb correspondently) and CGContextSetFillColor requires that appropriate color space is set (using CGContextSetFillColorSpace). Note also that docs say that prefered method to set fill color is CGContextSetFillColorWithColor
function.
来源:https://stackoverflow.com/questions/3060010/all-colors-work-except-whitecolor