【发布时间】:2012-06-11 08:58:46
【问题描述】:
我已经在 iOS 下主要使用 [NSString drawAtPoint] 创建了一些 PDF。
我的问题是:如何绘制线条和矩形?
以及如何绘制灰色框/框架作为背景层以在其中包含文本?
编辑:好的,我发现了一些关于绘制矩形的东西:renderInContext。
尽管如此,这段代码:
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(100, 240, 300, 150)];
[lbl setBackgroundColor:[UIColor redColor]];
[[lbl layer] renderInContext:currentContext];
正在绘制具有正确宽度/高度但原点错误 (0, 0) 的 UILabel!
知道为什么吗?
【问题讨论】:
-
使用
UIBezierPath实例来绘制线条或任何其他可以填充或描边的形状。