如何以一个角度绘制NSString? [英] How do I draw an NSString at an angle?

查看:114
本文介绍了如何以一个角度绘制NSString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一组字符串属性,我可以指定将绘制文本在一个角度,当我调用:

Is there a set of string attributes I can specify that will draw the text at an angle when I call:

[label drawAtPoint:textStart withAttributes:attributes];


推荐答案

这里有一个使用变换旋转绘图的示例上下文。基本上它就像设置一个颜色或阴影,只需确保使用 -concat 而不是 -set 。 p>

Here's an example that uses a transform to rotate the drawing context. Essentially it's just like setting a color or shadow, just make sure to use -concat instead of -set.

CGFloat rotateDeg = 4.0f;
NSAffineTransform *rotate = [[NSAffineTransform alloc] init];

[rotate rotateByDegrees:rotateDeg];
[rotate concat];

// Lock focus if needed and draw strings, images here.

[rotate release];

这篇关于如何以一个角度绘制NSString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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