我有一个UIView子类,我正在绘制PDF(使用CATiledLayer)。我还需要在该PDF的特定区域上绘制,但是当使用CG绘制时,CATiledLayer的坐标平面很复杂。
见图片:
我有一个点(200,200),我需要转换为CATiledLayer的坐标系,这是上面显示的第二个平面。我试过用一些变换来做这个,但似乎没什么用。
谢谢!
答案 0 :(得分:0)
以下是我必须做的事情(使用上面的示例点/平面):
//rotatation origin
CGPoint rotateOrigin = CGPointMake(0,0);
//rotatation transform
CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(rotateOrigin.x, rotateOrigin.y);
//rotate the plane 90 degrees
float radians = 90 * (M_PI / 180);
CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(radians); CGAffineTransform customRotation = CGAffineTransformConcat(CGAffineTransformConcat( CGAffineTransformInvert(translateTransform), rotationTransform), translateTransform);
CGAffineTransform m1 = CGAffineTransformIdentity;
CGPoint startPoint = CGPointApplyAffineTransform(CGPointMake(200,200),m1);
//rotated point
CGPoint rotatedPoint = CGPointApplyAffineTransform(startPoint, customRotation);
//final rotated point- after adjusting for the rotation
rotatedPoint = CGPointApplyAffineTransform(rotatedPoint, CGAffineTransformMakeTranslation(500,-500));