In this recipe, we will learn how to intercept and respond to user touches.
Perform the following steps:
Add a label to the view the controller.
Enter the following code in the
TouchEventsAppViewController
class:public override void TouchesMoved (NSSet touches, UIEvent evt) { base.TouchesMoved (touches, evt); UITouch touch = touches.AnyObject as UITouch; UIColor currentColor = this.View.BackgroundColor; float red, green, blue, alpha; currentColor.GetRGBA(out red, out green, out blue, out alpha); PointF previousLocation = touch.PreviousLocationInView(this.View); PointF touchLocation = touch.LocationInView(this.View); if (previousLocation.X != touchLocation.X) { this.lblOutput.Text = "Changing background color..."; float colorValue = touchLocation.X / this.View.Bounds.Width; this.View.BackgroundColor = UIColor.FromRGB(colorValue, colorValue...