我现在可以使用以下代码绘制一张图片,然后用手指画一幅画:
public override void Draw (RectangleF rect)
{
base.Draw (rect);
using (CGContext context = UIGraphics.GetCurrentContext()) {
// Draw image in context
context.DrawImage (rectangle, imageToDraw.CGImage);
// Draw finger touch
if (this.fingerDraw) {
context.SetStrokeColor (UIColor.Black.CGColor);
context.SetLineWidth (5f);
context.SetLineCap (CGLineCap.Round);
this.drawPath.MoveToPoint (this.prevTouchLocation);
this.drawPath.AddLineToPoint (this.touchLocation);
context.AddPath (this.drawPath);
context.DrawPath (CGPathDrawingMode.Stroke);
}
}
}
然而,这给我带来了性能问题,每次用户触摸屏幕时绘制图像都非常昂贵。
如何在开始时绘制ONCE图像然后只画手指触摸?
答案 0 :(得分:0)
不要在图像上画画。将图片放在fingerDraw
视图下方的视图中。