I am trying to use a WebView to display an HTML string, but I would like the background Image of the entire application to be visible in the WebView. I understand to do so, I would need to create a custom renderer for the WebView to make the control background itself transparent. While trying to actually achieve this effect I am constantly running into issues. Is there a good example somewhere of a custom WebView sub-class that does NOT require Xamarin.Forms.Labs to be included in the project?
This is my attempt at a custom renderer, but it currently displays nothing at all. Any suggestions or pointers on where to look would be appreciated, I have been looking around for a while at this point.
[assembly: ExportRenderer(typeof(TransparentWebView), typeof(TransparentWebViewRenderer))]
namespace TransparentWebViewTest.iOS
{
public class TransparentWebViewRenderer : ViewRenderer<TransparentWebView, UIWebView>
{
// Override the OnElementChanged method so we can tweak this renderer post-initial setup
protected override void OnElementChanged(ElementChangedEventArgs<TransparentWebView> e)
{
if (Control == null)
{
SetNativeControl(new UiWebView());
}
base.OnElementChanged(e);
Control.BackgroundColor = UIColor.Clear;
Control.Opaque = false;
}
}
}