绘制一次图像,然后用手指在上面绘图(MonoTouch)

时间:2014-11-13 20:07:12

标签: ios xamarin.ios xamarin

我现在可以使用以下代码绘制一张图片,然后用手指画一幅画:

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图像然后只画手指触摸?

1 个答案:

答案 0 :(得分:0)

不要在图像上画画。将图片放在fingerDraw视图下方的视图中。

相关问题