Page Status Bar Visibility on iOS
This iOS platform-specific is used to set the visibility of the status bar on a Page
, and it includes the ability to control how the status bar enters or leaves the Page
. It's consumed in XAML by setting the Page.PrefersStatusBarHidden
attached property to a value of the StatusBarHiddenMode
enumeration, and optionally the Page.PreferredStatusBarUpdateAnimation
attached property to a value of the UIStatusBarAnimation
enumeration:
<ContentPage ...
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.PrefersStatusBarHidden="True"
ios:Page.PreferredStatusBarUpdateAnimation="Fade">
...
</ContentPage>
Alternatively, it can be consumed from C# using the fluent API:
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...
On<iOS>().SetPrefersStatusBarHidden(StatusBarHiddenMode.True)
.SetPreferredStatusBarUpdateAnimation(UIStatusBarAnimation.Fade);
The Page.On<iOS>
method specifies that this platform-specific will only run on iOS. The Page.SetPrefersStatusBarHidden
method, in the Xamarin.Forms.PlatformConfiguration.iOSSpecific
namespace, is used to set the visibility of the status bar on a Page
by specifying one of the StatusBarHiddenMode
enumeration values: Default
, True
, or False
. The StatusBarHiddenMode.True
and StatusBarHiddenMode.False
values set the status bar visibility regardless of device orientation, and the StatusBarHiddenMode.Default
value hides the status bar in a vertically compact environment.
The result is that the visibility of the status bar on a Page
can be set:
Note
On a TabbedPage
, the specified StatusBarHiddenMode
enumeration value will also update the status bar on all child pages. On all other Page
-derived types, the specified StatusBarHiddenMode
enumeration value will only update the status bar on the current page.
The Page.SetPreferredStatusBarUpdateAnimation
method is used to set how the status bar enters or leaves the Page
by specifying one of the UIStatusBarAnimation
enumeration values: None
, Fade
, or Slide
. If the Fade
or Slide
enumeration value is specified, a 0.25 second animation executes as the status bar enters or leaves the Page
.