public void SetupGestureRecognizer() { _midPoint = new CGPoint(_handleImage.Frame.X + _handleImage.Frame.Size.Width / 2, _handleImage.Frame.Y + _handleImage.Frame.Size.Height / 2); _outRadius = _handleImage.Frame.Size.Width / 3 + 12.0f; _innerRadius = _outRadius / 2; if (_showTouchPath) { var bigCircle = new UICircleView(Bounds, _midPoint, _outRadius); var smallCircle = new UICircleView(Bounds, _midPoint, _innerRadius); Add(bigCircle); Add(smallCircle); } _imageAngle = _currentValue.ToCurrentAngle(_minValue, _maxValue); _handleImage.Transform = CGAffineTransform.MakeRotation(_imageAngle * ((float)Math.PI) / 180); _gestureRecognizer = new RotationGestureRecognizer(_midPoint, _innerRadius, _outRadius); _gestureRecognizer.RotationStarted += ((nfloat cumulatedAngle) => { _imageAngle += cumulatedAngle; if (_imageAngle < -145) { _imageAngle = -145; } else if (_imageAngle > 145) { _imageAngle = 145; } InvokeOnMainThread(() => { // Rotate image and update text field _handleImage.Transform = CGAffineTransform.MakeRotation(_imageAngle * ((float)Math.PI) / 180); _currentValue = _imageAngle.ToCurrentValue(_minValue, _maxValue); _valueLabel.Text = Convert.ToInt32(_currentValue).ToString(); if (RotationEnded != null) { RotationEnded(_currentValue); } }); }); _gestureRecognizer.Rotating += (nfloat angle) => { // Calculate rotation angle _imageAngle += angle; /* * // Use this setting if you want to go round and round endlessly * if (imageAngle > 360) * imageAngle -= 360; * else if (imageAngle < -360) * imageAngle += 360; */ Console.WriteLine("_imageAngle = {0}", _imageAngle); if (_imageAngle < -145) { _imageAngle = -145; } else if (_imageAngle > 145) { _imageAngle = 145; } InvokeOnMainThread(() => { // Rotate image and update text field _handleImage.Transform = CGAffineTransform.MakeRotation(_imageAngle * ((float)Math.PI) / 180); _currentValue = _imageAngle.ToCurrentValue(_minValue, _maxValue); _valueLabel.Text = Convert.ToInt32(_currentValue).ToString(); if (RotationEnded != null) { RotationEnded(_currentValue); } }); }; _gestureRecognizer.RotationEnded += (nfloat obj) => { Console.WriteLine("CurrentValue = " + _imageAngle.ToCurrentValue(_minValue, _maxValue)); _currentValue = _imageAngle.ToCurrentValue(_minValue, _maxValue); _valueLabel.Text = Convert.ToInt32(_currentValue).ToString(); if (RotationEnded != null) { RotationEnded(_currentValue); } }; AddGestureRecognizer(_gestureRecognizer); }