Я пробовал с общим кодом, на моем локальном сайте нет проблем, не имеет значения в Xamarin. iOS или Xamarin.Forms проекта. Действуйте следующим образом:
![enter image description here](https://i.stack.imgur.com/fvsm4.png)
При использовании общего кода необходимо писать в AppDelegate.cs
. Если запись в другом месте, например в Sub-ViewController, не будет работать.
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
global::Xamarin.Forms.FormsMaterial.Init();
LoadApplication(new App());
Console.WriteLine("------13--------");
UINavigationBar.Appearance.BackgroundColor = UIColor.Orange;
UINavigationBar.Appearance.BarTintColor = UIColor.Orange;
UINavigationBar.Appearance.TintColor = UIColor.White;
UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes()
{
ForegroundColor = UIColor.White
};
return base.FinishedLaunching(app, options);
}
}
Кроме того, , из общего снимка экрана, цвет был установлен для NavigationBar. Тем не менее, он был переопределен другим цветом. Я думаю, что где-то написанный код влияет на это.
Кстати, есть способы Xamarin Forms, чтобы установить цвет для панели навигации. Вы также можете использовать это или проверить, уже использовали ли вы его в проекте.
App.xaml.cs :
NavigationPage navigationPage = new NavigationPage(new MainPage());
navigationPage.BarBackgroundColor = Color.White;
navigationPage.BarTextColor = Color.Black;
MainPage = navigationPage;