本文介绍了除白色外,所有颜色均有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]);
CGContextSetFillColor(context, color);

我有黑色背景.在处理上面的代码时,不确定什么是错误的,大多数颜色都可以工作,例如redColor,purpleColor,greenColor,yellowColor
但whiteColor,grayColor不起作用.当我使用whiteColor屏幕看起来是空的.

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.

推荐答案

whiteColor greyColor 的色彩空间与 redColor PurpleColor 等(我猜对应地为灰色和rgb),并且CGContextSetFillColor要求设置适当的颜色空间(使用CGContextSetFillColorSpace).还要注意,文档说设置填充颜色的首选方法是 CGContextSetFillColorWithColor 函数.

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.

这篇关于除白色外,所有颜色均有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 22:59