石英绘图在变换后的视图上变慢

时间:2013-08-30 13:04:46

标签: ios uiview drawrect quartz-2d cgaffinetransform

如果我将2000x2000 UIView转换为200x200(使用myView.transform = CGAffineTransformScale(...)),则绘图速度极慢。

绘图代码非常简单:

-drawRect:

    CGContextAddPath(context, activePath);
    CGContextSetLineWidth(context, self.strokeWidth);
    CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
    CGContextSetLineJoin(context, kCGLineJoinRound);
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextStrokePath(context);

我是否需要做任何特别的事情来提高绘图性能?

P.S。只要我不转换绘图画布视图,我就会获得非常好的绘图性能。即约60 fps。

p.p.s。视图层次结构如下所示:

UIView
UIView > UIView (controls)
UIView > UIView (drawing container)
UIView > UIView (drawing container) > UIView (background view)
UIView > UIView (drawing container) > UIView (drawing canvas)

也许我的绘图代码不是问题;也许慢性能与我的视图层次结构有关。即使我不使用任何背景图像,我的绘图性能也会变慢,并且使绘图画布的背景保持白色。有小费吗?

0 个答案:

没有答案
相关问题