Search code examples
uno-platform

[iOS][Android]: How to hide the status bar with platform UNO?


How would I hide the status bar on top of the screen in iOS (and Android).

Believe, Xamarin.Forms has a way to do that. But how would I do that with Platform UNO?

Thanks in advance

Dierk


Solution

  • Uno Platform supports the UWP StatusBar API on Android and iOS, you can hide and show the status bar in the following manner:

            private void HideStatusBar()
            {
                var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
    
                Windows.UI.Xaml.Window.Current.Dispatcher.RunAsync(
                    Windows.UI.Core.CoreDispatcherPriority.Normal,
                    async () => await statusBar.HideAsync()
                );
            }
    
            private void ShowStatusBar()
            {
                var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
    
                Windows.UI.Xaml.Window.Current.Dispatcher.RunAsync(
                    Windows.UI.Core.CoreDispatcherPriority.Normal,
                    async () => await statusBar.ShowAsync()
                );
            }