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