[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
MessagingCenter.Subscribe<Page, bool>(this, "ModeChanged", callback: OnModeChanged);
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
private void OnModeChanged(Page page, bool IsDarkModeEnabled)
{
if (IsDarkModeEnabled)
Window.OverrideUserInterfaceStyle = UIUserInterfaceStyle.Dark;
else
Window.OverrideUserInterfaceStyle = UIUserInterfaceStyle.Light;
}
}
我想做的是在故事板出现之前通过检查一些存储的数据进行更改(我不确定我可以检查什么)。
在情节提要出现之前,有没有一种方法可以使用,我可以访问存储的信息来告诉我我的应用程序是在内部亮还是暗模式下运行?
在我的AppDelegate中,我有一种方法可以更改UIUserInterfaceStyle:[Register(“ AppDelegate”)]公共部分类AppDelegate:global :: Xamarin.Forms.Platform.iOS.FormsApplicationDelegate {...