【发布时间】:2011-09-26 23:10:10
【问题描述】:
UIGraphicsBeginImageContext(self.view.bounds.size);
[currentStrokeImageView.image drawInRect:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeNormal);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), dWidth);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), r, g, b, 1.0f);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), pointA.x, pointA.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), pointB.x, pointB.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
currentStrokeImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
由于某种原因,这在 iphone/ipod 上运行绝对没有延迟,但在 iPad 上,绘图时出现明显的延迟。我使用的代码在上面,有什么建议可以解决这个问题吗?
【问题讨论】:
-
了解上面的代码在什么上下文(rimshot!)中执行会很有帮助。
-
你在什么情况下是什么意思?当用户拖动手指时,它在 self.view 内,请详细说明,因为我不太清楚你的意思(有点初学者)
-
这段代码是通过什么方法调用的?
标签: iphone memory core-graphics lag