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

查看:27
本文介绍了如何以一定角度绘制 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.

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天全站免登陆