In this recipe, we will use the techniques we learned to create a drawing app.
Create a new Single View Application in Xamarin Studio and name it FingerDrawingApp
. Once again, we will need a custom view. Add a class deriving from UIView
and name it CanvasView
.
Perform the following steps:
Implement the
CanvasView
class with the following code:public class CanvasView : UIView { public CanvasView (RectangleF frame) : base(frame) { this.drawPath = new CGPath(); } private PointF touchLocation; private PointF previousTouchLocation; private CGPath drawPath; private bool fingerDraw; public override void TouchesBegan (NSSet touches, UIEvent evt) { base.TouchesBegan (touches, evt); UITouch touch = touches.AnyObject as UITouch; this.fingerDraw = true; this.touchLocation = touch.LocationInView(this); this.previousTouchLocation = touch.PreviousLocationInView(this); this.SetNeedsDisplay(); } public override...