【发布时间】:2011-06-30 04:09:58
【问题描述】:
我正在尝试从石英椭圆的中心绘制径向线。
CGContextSetRGBStrokeColor(ctx, 0.0, 1.0, 1.0, 1.0); //cyan stroke
CGContextSetLineWidth(ctx, 2.0);
CGContextFillEllipseInRect(ctx, oRect);
CGContextSaveGState(ctx);
CGPoint center = CGPointMake(CGRectGetMidX(oRect), CGRectGetMidY(oRect));
CGFloat maxX = CGRectGetMaxX(oRect);
for(int i = 0; i < 5; i++) {
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, maxX, center.y);
CGContextAddLineToPoint(ctx, center.x, center.y);
CGContextClosePath(ctx);
CGContextStrokePath(ctx);
CGContextRotateCTM(ctx, degreesToRadians(5.0));
}
CGContextRestoreGState(ctx);
结果:
不是从椭圆中心发出的线条图,而是随着矩阵的每次变换而移动。为什么中心是重置而不是旋转?
【问题讨论】:
标签: iphone objective-c ipad quartz-2d cgcontext