// Zoom the image by the current scale
[Export("ScaleImage")]
void ScaleImage (UIPinchGestureRecognizer gestureRecognizer)
{
AdjustAnchorPointForGestureRecognizer (gestureRecognizer);
if (gestureRecognizer.State == UIGestureRecognizerState.Began || gestureRecognizer.State == UIGestureRecognizerState.Changed)
{
gestureRecognizer.View.Transform *= CGAffineTransform.MakeScale (gestureRecognizer.Scale, gestureRecognizer.Scale);
// Reset the gesture recognizer's scale - the next callback will get a delta from the current scale.
gestureRecognizer.Scale = 1;
}
}
void AdjustAnchorPointForGestureRecognizer (UIGestureRecognizer gestureRecognizer)
{
if (gestureRecognizer.State == UIGestureRecognizerState.Began)
{
var image = gestureRecognizer.View;
var locationInView = gestureRecognizer.LocationInView (image);
var locationInSuperview = gestureRecognizer.LocationInView (image.Superview);
image.Layer.AnchorPoint = new PointF (locationInView.X / image.Bounds.Size.Width, locationInView.Y / image.Bounds.Size.Height);
image.Center = locationInSuperview;
}
}
// Zoom the image by the current scale
[Export("ScaleImage")]
void ScaleImage (UIPinchGestureRecognizer gestureRecognizer)
{
AdjustAnchorPointForGestureRecognizer (gestureRecognizer);
if (gestureRecognizer.State == UIGestureRecognizerState.Began || gestureRecognizer.State == UIGestureRecognizerState.Changed)
{
gestureRecognizer.View.Transform *= CGAffineTransform.MakeScale (gestureRecognizer.Scale, gestureRecognizer.Scale);
// Reset the gesture recognizer's scale - the next callback will get a delta from the current scale.
gestureRecognizer.Scale = 1;
}
}