共用方式為


iOS 上的頁面狀態列可見度

這個 iOS 平臺特定是用來設定 上 Page狀態列的可見性,而且它包含控制狀態列如何進入或離開 Page的功能。 它會在 XAML 中取用,方法是將附加屬性設定 Page.PrefersStatusBarHidden 為 列舉值 StatusBarHiddenMode ,並選擇性地將 Page.PreferredStatusBarUpdateAnimation 附加屬性設定為 列舉值 UIStatusBarAnimation

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             ios:Page.PrefersStatusBarHidden="True"
             ios:Page.PreferredStatusBarUpdateAnimation="Fade">
  ...
</ContentPage>

或者,您可以使用 Fluent API 從 C# 取用它:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

On<iOS>().SetPrefersStatusBarHidden(StatusBarHiddenMode.True)
         .SetPreferredStatusBarUpdateAnimation(UIStatusBarAnimation.Fade);

方法 Page.On<iOS> 會指定此平台專屬只會在iOS上執行。 命名空間Page.SetPrefersStatusBarHidden中的 Xamarin.Forms.PlatformConfiguration.iOSSpecific 方法會藉由指定其中StatusBarHiddenMode一個列舉值,來設定 上Page狀態列的可見性:DefaultTrueFalseStatusBarHiddenMode.TrueStatusBarHiddenMode.False 值會設定狀態列可見性,而不論裝置方向為何,值StatusBarHiddenMode.Default都會隱藏垂直精簡環境中的狀態列。

結果是可以設定狀態列的 Page 可見性:

狀態列可見度平臺特定

注意

TabbedPage在 上,指定的StatusBarHiddenMode列舉值也會更新所有子頁面上的狀態列。 在所有其他 Page衍生型別上,指定的 StatusBarHiddenMode 列舉值只會更新目前頁面上的狀態列。

方法 Page.SetPreferredStatusBarUpdateAnimation 可用來設定狀態列如何輸入或離開 Page ,方法是指定其中 UIStatusBarAnimation 一個列舉值: NoneFadeSlideFade如果指定 或 Slide 列舉值,0.25 秒動畫會在狀態列進入或離開 Page時執行。