Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何设置字体颜色?_Ios - Fatal编程技术网

Ios 如何设置字体颜色?

Ios 如何设置字体颜色?,ios,Ios,下面的代码正在将文本绘制到图像上,但它是黑色的,我需要更改颜色。有什么建议吗 UIFont* font = [UIFont systemFontOfSize:250]; NSDictionary *attributes = @{NSFontAttributeName: font}; CGSize size = [WmarText sizeWithAttributes:attributes]; // Create a bitmap context into which the text will

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

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];

将带有[UIColor whiteColor]的NSForegroundColorAttributeName添加到属性字典。请参见将带有[UIColor whiteColor]的NSForegroundColorAttributeName添加到属性字典。请参见将带有[UIColor whiteColor]的NSForegroundColorAttributeName添加到属性字典。请参见将带有[UIColor whiteColor]的NSForegroundColorAttributeName添加到属性字典。请参见

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

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

我想这就成功了。

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

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

我想这就成功了。

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

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

我想这就成功了。

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

NSDictionary *attributes = @{ NSFontAttributeName: font,
                              NSForegroundColorAttributeName: [UIColor whiteColor]};
我想这就是关键所在。

再加上:

NSForegroundColorAttributeName: [UIColor whiteColor]
在属性中添加以下内容:

NSForegroundColorAttributeName: [UIColor whiteColor]
在属性中添加以下内容:

NSForegroundColorAttributeName: [UIColor whiteColor]
在属性中添加以下内容:

NSForegroundColorAttributeName: [UIColor whiteColor]
进入你的属性