Reputation: 117
In my dotnet maui app (version 8) I have a WebView and I want to change the background color to black with a handler in the iOS platform. In Android platform I can change in directly on the control like this:
<WebView Grid.Row="0" x:Name="webView" HeightRequest="250" BackgroundColor="{StaticResource Gray800}"></WebView>
But that doesn't take effect on iOS so I've tried to make it work with a handler without success.
How can I achieve this?
Upvotes: 1
Views: 562
Reputation: 8220
You may try adding the following code in code behind,
public MainPage()
{
InitializeComponent();
ModifyWebView();
}
void ModifyWebView()
{
Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
{
#if IOS || MACCATALYST
handler.PlatformView.Opaque = false;
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
#endif
});
}
For more info, you could refer to Customize controls with handlers.
Upvotes: 1