我有一个 UIView 子类,我正在将 PDF 绘制到(使用 CATiledLayer)。我还需要在该 PDF 的特定区域上进行绘制,但是使用 CG 绘制时 CATiledLayer 的坐标平面非常复杂。
见图片:
我有一个点 (200,200),我需要将其转换为 CATiledLayer 的坐标系,即上面显示的第二个平面。我已经尝试通过一些转换来做到这一点,但似乎没有任何效果。
谢谢!
我有一个 UIView 子类,我正在将 PDF 绘制到(使用 CATiledLayer)。我还需要在该 PDF 的特定区域上进行绘制,但是使用 CG 绘制时 CATiledLayer 的坐标平面非常复杂。
见图片:
我有一个点 (200,200),我需要将其转换为 CATiledLayer 的坐标系,即上面显示的第二个平面。我已经尝试通过一些转换来做到这一点,但似乎没有任何效果。
谢谢!
这是我必须做的(使用上面的示例点/平面):
//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));