【发布时间】:2011-12-18 06:41:06
【问题描述】:
我是 Quartz 2D 的新手。我正在尝试绘制一个三角形然后旋转。由于我使用 Quartz 2D 的背景有限,我从 Apple/谷歌搜索中发现我可以使用 CGContextRotateCTM 函数。我的问题是当我这样做时,我绘制的整个文本也被旋转了。我尝试使用CGContextSaveGstate 并在我进行旋转后恢复它但没有工作。我想知道我的方法是否正确?或者我可以使用更好的方法来实现这一目标?
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
for (key in data)
{
// get point
Data *tmpdata =[data objectForKey:key] ;
point=[data point ]
//setup and draw the
CGContextBeginPath(context);
CGContextSetRGBFillColor(context, [data fillcolor].r,
[data fillcolor].g, [tmpACdata fillcolor].b, 1);
CGContextSetLineWidth(context, 2.0
// Draw Triangle
CGContextMoveToPoint(context,point.x,point.y);
CGContextAddLineToPoint(context, point.x+8, point.y+8);
CGContextAddLineToPoint(context, point.x-8, point.y+8);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextRotateCTM(context, [data heading]* M_PI/180);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
// Draw Text
...............
}
CGContextRestoreGState(context);
【问题讨论】: