【问题标题】:How to put CGContextScaleCTM and CGContextTranslateCTM outside of drawRect?如何将 CGContextScaleCTM 和 CGContextTranslateCTM 放在 drawRect 之外?
【发布时间】:2013-02-07 16:37:58
【问题描述】:

我是这种路径绘制的初学者,但是在显示地图时,我意识到 CGContextScaleCTM 和 CGContextTranslateCTM 在我的 drawRect 中占用了大量时间。 把那些带到外面就好了。因为我总是画同一张地图,我认为这应该是可能的。但是怎么做呢?

【问题讨论】:

    标签: ios drawrect cgcontext scaletransform


    【解决方案1】:

    可以这样扩展:

    CGAffineTransform currentTransform = myView.transform;
    CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, 0.5, 0.5);
    [myView setTransform:newTransform];
    

    并以类似的方式对 x/y 使用 CGAffineTransformTranslate。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多