下面的代码正在将文本绘制到图像上,但是它是黑色的,我需要更改颜色。有什么建议么?

UIFont* font = [UIFont systemFontOfSize:250];
NSDictionary *attributes = @{NSFontAttributeName: font};
CGSize size = [WmarText sizeWithAttributes:attributes];
// Create a bitmap context into which the text will be rendered.
UIGraphicsBeginImageContext(size);
// Render the text
[[UIColor whiteColor] setFill];
[WmarText drawAtPoint:CGPointMake(0, 0) withAttributes:attributes];

最佳答案

您是否尝试过在属性变量中设置颜色?像这样:

NSDictionary *attributes = @{ NSFontAttributeName: font,
                              NSForegroundColorAttributeName: [UIColor whiteColor]};


我认为这可以解决问题。

关于ios - 如何设置字体颜色?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22815014/

10-12 05:58