I was able to use the Custom renderer approach, in Xamarin forms to display a Signature Pad on the iOS platform.
I used this tutorial for that: https://blog.xamarin.com/using-custom-uiviewcontrollers-in-xamarin-forms-on-ios/
This is how the code looks at the moment:
In the shared code
namespace PCL.CustomControls
{
public class SignaturePad:ContentPage
{
public SignaturePad()
{
BackgroundColor = Color.Red;
}
}
}
In the iOS platform specific project: (This works great)
[assembly: ExportRenderer(typeof(SignaturePad), typeof(SignaturePad_iOS))]
namespace PCL.iOS.CustomRenderer
{
public class SignaturePad_iOS:PageRenderer
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
var signature = new SignaturePadView(View.Frame);
signature.StrokeColor = UIColor.Red;
signature.SignatureLineColor = UIColor.Black;
signature.BackgroundColor = UIColor.Yellow;
View.AddSubview(signature);
}
}
}
For Android I am trying the following, unfortunately I cannot use OnCreate, so that has put me in trouble in Xamarin Forms in this scenario:
[assembly: ExportRenderer(typeof(SignaturePad), typeof(SignaturePad_Droid))]
namespace PCL.Droid.CustomRenderer
{
public class SignaturePad_Droid:PageRenderer
{
base.OnCreate (bundle);
var signature = new SignaturePadView (this) {
LineWidth = 3f
};
AddContentView (signature,
new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
}
}
Can someone help me with the Droid imp0lementation.
Thanks