All colors work except whiteColor

只谈情不闲聊 提交于 2020-01-05 05:51:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!