A simple example of creating a custom ViewRenderer
in your PCL project, create something that infers from the view:
public class CustomMap: View { public static readonly BindableProperty PinsItemsSourceProperty = BindableProperty.Create ("PinsItemsSource ", typeof(IEnumerable), typeof(CustomMap), null, BindingMode.OneWay, null, null, null, null); public IEnumerable PinsItemsSource { get { return (IEnumerable)base.GetValue (CustomMap.PinsItemsSourceProperty ); } set { base.SetValue (CustomMap.PinsItemsSourceProperty , value); } } }
Then on your iOS, create your own renderer for this view as follows:
[assembly: ExportRenderer(typeof(CustomMap), typeof(CustomMapRenderer ))] namespace Xamarin.Forms.Labs.iOS.Controls { public class CustomMapRenderer : ViewRenderer<CustomMap,MKMapView > { protected override void OnElementChanged (ElementChangedEventArgs<CustomMap> e) { base.OnElementChanged (e); var mapView = new MKMapView (this.Bounds); mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; foreach(item in e.NewElement.PinsItemsSource ) {
ps: I wrote this code "on the fly" from my head, and I have not tested it, but it should help you get away.
source share