I have a VS2019 for mac cross platform Xamarin Forms 4 app. I used the basic template to create it.
In my App.xaml.cs file I just set the MainPage to my ContentPage object.
This content page has the backgroundcolor set to black.
When I run it on my iPhone I get the following results. Notice how the top of the screen and the bottom both have white backgrounds. I can't seem to figure out where that is coming from.
I tried wrapping my content page in a NavigationPage and settings its background to black, but all that does it add a little more black at the top of my contentpage and move the rest of the page down.
I can't figure out where the background color for the top and bottom outside of my content page is being set.
Can someone tell me?
UPDATE: Added some things asked for in the comments:
App.xaml:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="UpdateAgent.App">
<Application.Resources>
</Application.Resources>
</Application>
App.xaml.cs:
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace UpdateAgent
{
public partial class App : Application
{
Interfaces.IStartup Startup;
public App()
{
InitializeComponent();
Xamarin.Forms.DependencyService.Get<Interfaces.IStartup>().Init();
MainPage = new WebUpdatePage();
}
}
}
Visual Studio 2019 for Mac is latest version. Just updated the other day and when I check for updates there are not any.
I am using an iPhone XS Max not the simulator.
After seeing the comment I tried it out in the simulator the iPhone 12 Pro Max - 14.2 just to see if it was any different. It does the same thing.
UPDATE 2: Decided to add the WebUpdatePage xaml and class figuring it would be asked for eventually. Here they are:
WebUpdatePage.xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HybridWebViewMobile;assembly=HybridWebViewMobile"
x:Class="UpdateAgent.WebUpdatePage"
BackgroundColor="Black">
<ContentPage.Content>
<local:HybridWebView x:Name="hybridWebView" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
</ContentPage.Content>
</ContentPage>
WebUpdatePage.xaml.cs:
using Xamarin.Forms;
using Devices.Communication.Mobile;
namespace UpdateAgent
{
public partial class WebUpdatePage : ContentPage
{
public WebUpdatePage()
{
InitializeComponent();
DependencyService.Get<IConnectDevice>().RegisterDetectors(hybridWebView).Wait();
DependencyService.Get<IConnectDevice>().Jsonfunctions(hybridWebView);
}
}
}
UPDATE 3:
Here is information about the HybridWebView:
The first iOS class is this:
[assembly: ExportRenderer(typeof(HybridWebView),typeof(HybridWebViewRenderer))]
namespace UpdateAgent.iOS
{
public class HybridWebViewRenderer : HybridWebViewRendererMobile
{
public HybridWebViewRenderer()
{
}
}
}
The second iOS implementation partially looks like this (only show the relevant parts):
public class HybridWebViewRendererMobile : WkWebViewRenderer, IWKScriptMessageHandler
{
const string JavaScriptFunction = "function invokeCSharpAction(data){window.webkit.messageHandlers.invokeAction.postMessage(data);}";
WKUserContentController userController;
public HybridWebViewRendererMobile() : this(new WKWebViewConfiguration())
{
}
public HybridWebViewRendererMobile(WKWebViewConfiguration config) : base(config)
{
userController = config.UserContentController;
var script = new WKUserScript(new NSString(JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
userController.AddUserScript(script);
userController.AddScriptMessageHandler(this, "invokeAction");
}
