In this recipe, we will use the techniques that we learned to create a drawing application.
Create a new project in MonoDevelop, and name it FingerDrawingApp
. Once again, we will need a custom view. Add a class deriving from UIView,
and name it CanvasView
.
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 void TouchesMoved (NSSet touches...