use "Application.Current.UserAppTheme = AppTheme.Light" force application theme light, the first line of iphone will disappear when system is dart theme

Fei Xu 490 Reputation points
2023-10-02T14:54:57.8166667+00:00

Application.Current.UserAppTheme = AppTheme.Light;

I want to set the application theme light, use the upper line code , but when ios system theme is dark , first line of iphone (time signal..) will display with white textcolor, then will disappear on application light theme.

How can I let first line of iphone appear on application light theme , when system theme is dark ?

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-10-03T04:21:02.1833333+00:00

    Hello,

    That line you mentioned is Status bar on iOS. The text color defaults to black, and the background is also black when system theme is dark, so it looks like that line disappears.

    You could try using .NET MAUI Community Toolkit StatusBarBehavior and setting LightContent when the theme is dark, which will change the text color to white. (And setting DarkContent when the theme is light)

    Application.Current.UserAppTheme = AppTheme.Dark;
                // CommunityToolkit.Maui.Core.Platform.StatusBar.SetColor(Colors.Yellow);
                CommunityToolkit.Maui.Core.Platform.StatusBar.SetStyle(CommunityToolkit.Maui.Core.StatusBarStyle.LightContent);
    

    Note: In the Platforms/iOS/Info.plist file, add UIViewControllerBasedStatusBarAppearance key and value.

    <key>UIViewControllerBasedStatusBarAppearance</key>
        <false/>
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.