下面的代码正在将图像绘制到图像上,但它是黑色的,我需要更改颜色。有什么建议吗?
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];
答案 0 :(得分:2)
您是否尝试过设置属性变量中的颜色?像这样:
NSDictionary *attributes = @{ NSFontAttributeName: font,
NSForegroundColorAttributeName: [UIColor whiteColor]};
我认为这可以解决问题。
答案 1 :(得分:1)
将带有[UIColor whiteColor]的NSForegroundColorAttributeName添加到属性字典中。见https://developer.apple.com/library/mac/documentation/cocoa/Conceptual/AttributedStrings/Articles/standardAttributes.html#//apple_ref/doc/uid/TP40004903-SW2
答案 2 :(得分:0)
添加:
NSForegroundColorAttributeName: [UIColor whiteColor]
进入你的属性