如何在drawAtPoint中更改NSString的颜色 [英] How to change color of NSString in drawAtPoint

查看:44
本文介绍了如何在drawAtPoint中更改NSString的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有这段代码,它绘制了一个带有一个字符字符串的块:

I have this chunk of code here that draws a block with a one-character string on it:

CGContextDrawImage(context, CGRectMake([blok getLocation].x * xunit, [blok getLocation].y * yunit, 40, 40), [blok getImage].CGImage);
[[blok getSymbol] drawAtPoint:CGPointMake([blok getLocation].x * xunit+15, [blok getLocation].y * yunit) withFont:[UIFont fontWithName:@"Helvetica" size:24]];

它工作正常,但是我一直在进行一些布局更改,现在我需要它,以便绘制的字符串为白色.使用设置填充颜色和笔触颜色的方法没有做任何事情.还有其他方法吗?

It's working fine, but I've been doing some layout changes, and now I need it so that the string drawn will be white. Using the methods for setting the fill color and the stroke color haven't done anything. Is there some other way to do this?

推荐答案

您是否尝试过:

CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), textColor);

例如:

CGContextDrawImage(context, CGRectMake([blok getLocation].x * xunit, [blok getLocation].y * yunit, 40, 40), [blok getImage].CGImage);
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), textColor);
[[blok getSymbol] drawAtPoint:CGPointMake([blok getLocation].x * xunit+15, [blok getLocation].y * yunit) withFont:[UIFont fontWithName:@"Helvetica" size:24]];

这篇关于如何在drawAtPoint中更改NSString的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆