2011-03-07 62 views
0

我绘制了2条直线,但我想旋转角度的第一条线?在上下文中旋转一条线?

CGContextBeginPath(context); 
    CGContextSetLineWidth(context, 10.0); 
    CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor); 
    CGContextMoveToPoint(context, 65, 40); 
    CGContextAddLineToPoint(context,165, 40); 
    CGContextStrokePath(context); 
    CGContextClosePath(context); 

    CGContextBeginPath(context); 
    CGContextSetLineWidth(context, 10.0); 
    CGContextSetStrokeColorWithColor(context,[UIColor blackColor].CGColor); 
    CGContextMoveToPoint(context, 85, 80); 
    CGContextAddLineToPoint(context, 185, 80); 
    CGContextStrokePath(context); 
    CGContextClosePath(context); 

回答

1

您应该使用CGAffineTransformMakeRotation。

CGAffineTransform rotation = CGAffineTransformMakeRotation(theAngle); 
    CGContextConcatCTM(context, rotation); 

好运