Reputation: 95
When I attempt this:
https://learn.microsoft.com/en-us/xamarin/essentials/app-theme?tabs=ios
appTheme is always Light, regardless of my simulator or device Dark setting.
I also tried this:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/system-theme-changes
But I can't find the code that fetches the Settings theme.
Your help is appreciated!
Thanks! Larry
Upvotes: 1
Views: 140
Reputation: 74124
UIKit.TraitCollection.UserInterfaceStyle
contains the current app|view dark/light setting
if (this.TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark)
{
// dark
}
else
{
// light
}
re: https://learn.microsoft.com/en-us/dotnet/api/uikit.uiuserinterfacestyle?view=xamarin-ios-sdk-12
"Still always returning light."
If your info.plist
contains an UIUserInterfaceStyle
entry that is set to Light
it will override the OS setting. Either remove this entry or set it to Automatic
.
Upvotes: 1