Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created August 1, 2017 23:45
Show Gist options
  • Save rdelrosario/b1abb918fa0d5c51cbcdf7189b53e7e4 to your computer and use it in GitHub Desktop.
Save rdelrosario/b1abb918fa0d5c51cbcdf7189b53e7e4 to your computer and use it in GitHub Desktop.
Zoomable ScrollView iOS Renderer
using ZoomableApp.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using System.Linq;
[assembly: ExportRenderer(typeof(ScrollView), typeof(ZoomScrollViewRenderer))]
namespace ZoomableApp.iOS.Renderers
{
public class ZoomScrollViewRenderer : ScrollViewRenderer
{
// bool zoomEnabled = false;
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
MaximumZoomScale = 3f;
MinimumZoomScale = 1.0f;
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
if(Subviews.Length > 0)
{
ViewForZoomingInScrollView += GetViewForZooming;
}
else
{
ViewForZoomingInScrollView -= GetViewForZooming;
}
}
public UIView GetViewForZooming(UIScrollView sv)
{
return this.Subviews.FirstOrDefault();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment