Quartz 2D를 처음 사용했습니다. 삼각형을 그려서 회전하려고합니다. Quartz 2D를 사용하는 나의 제한된 배경에서 나는 Apple/googling에서 발견하여 CGContextRotateCTM
함수를 사용할 수있다. 내 문제는 그 이후에 그려진 전체 텍스트도 회전된다는 것입니다. CGContextSaveGstate
을 사용하여 시도하고 난 후 회전하지만 didnt 작업을 복원. 내 접근 방식이 맞는지 궁금하네요? 아니면 그것을 달성하는 데 사용할 수있는 더 나은 방법이 있습니까?석영 2D 드로잉 프리미티브 회전
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);
로직을 시도했지만 작동하지 않았습니다. 이제 텍스트가 표시되지만 삼각형은 표시되지 않습니다. – user519274
좌표에 문제가있는 경우 관련 행이있는 코드를 입력하십시오. 아니면'std :: cout << yourVariable << "\ n"을 던져라. – Adrian