【问题标题】:Convert CGPoint between iPhone & CA planes在 iPhone 和 CA 飞机之间转换 CGPoint
【发布时间】:2010-09-02 18:40:13
【问题描述】:

我有一个 UIView 子类,我在上面绘制 PDF(使用 CATiledLayer)。我还需要在该 PDF 的特定区域上进行绘制,但是使用 CG 绘制时 CATiledLayer 的坐标平面非常复杂。

看图:

我有一个点 (200,200),我需要将其转换为 CATiledLayer 的坐标系,即上面显示的第二个平面。我已经尝试通过一些转换来做到这一点,但似乎没有任何效果。

谢谢!

【问题讨论】:

    标签: iphone core-animation core-graphics cgaffinetransform catiledlayer


    【解决方案1】:

    这是我必须做的(使用上面的示例点/平面):

    //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));   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-25
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 2015-06-28
      相关资源
      最近更新 更多