此 iOS 平台特定内容用于设置模式页的演示样式,此外,还可用于显示具有透明背景的模式页。 通过将 Page.ModalPresentationStyle 可绑定属性设置为 UIModalPresentationStyle 枚举值在 XAML 中使用它:
<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             ios:Page.ModalPresentationStyle="OverFullScreen">
    ...
</ContentPage>
或者,可以使用 Fluent API 从 C# 使用它:
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...
public class iOSModalFormSheetPageCS : ContentPage
{
    public iOSModalFormSheetPageCS()
    {
        On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.OverFullScreen);
        ...
    }
}
该 Page.On<iOS> 方法指定此平台特定仅在 iOS 上运行。 Xamarin.Forms.PlatformConfiguration.iOSSpecific 命名空间中的 Page.SetModalPresentationStyle 方法用于通过指定以下任一 UIModalPresentationStyle 枚举值来设置 Page 上的模式呈现样式:
- FullScreen,用于设置模式呈现样式以包含整个屏幕。 默认情况下,使用此呈现样式显示模式页面。
- FormSheet,用于将模式呈现样式设置为屏幕居中且小于屏幕。
- Automatic,用于将模式呈现样式设置为系统选择的默认样式。 对于大多数视图控制器,- UIKit将其映射到- UIModalPresentationStyle.PageSheet,但某些系统视图控制器可能会将其映射到其他样式。
- OverFullScreen,用于设置模式呈现样式以覆盖屏幕。
- PageSheet,用于设置模式呈现样式以覆盖基础内容。
此外,GetModalPresentationStyle 方法还可用于检索应用于 Page 的 UIModalPresentationStyle 枚举的当前值。
结果是可以设置 Page 上的模式呈现样式:
注意
使用此平台特定设置模式呈现样式的页面必须使用模式导航。 有关详细信息,请参阅 Xamarin.Forms模式页。
