【问题标题】:Add Transparent Background Color to Popup Page for MAUI using Community Toolkit in iOS在 iOS 中使用 Community Toolkit 为 MAUI 的弹出页面添加透明背景色
【发布时间】:2022-11-18 11:57:13
【问题描述】:

我开始使用 .NET MAUI。 已安装社区工具包以显示弹出窗口。 弹出式 UI 在 iOS 中不显示透明背景颜色,而在 Android 中它工作得很好。

安卓:

iOS:

为弹出窗口添加了 XAML 文件: 弹出:

<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="testpopup.PopupPage"
             xmlns:mct="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
             >
    <VerticalStackLayout BackgroundColor="Transparent">
        <Label 
            Text="Welcome to .NET MAUI!"
            VerticalOptions="Center" 
            HorizontalOptions="Center" />
    </VerticalStackLayout>
</mct:Popup>

我刚刚修改了 MainPage 上的按钮以显示弹出窗口:

private void OnCounterClicked(object sender, EventArgs e)
    {
        this.ShowPopup(new PopupPage());
    }

任何帮助表示赞赏!

【问题讨论】:

  • 您还可以将 BackgroundColor="Transparent" 添加到 Popup 本身吗?在前几行,x:Class附近?如果这没有帮助(或被编​​译器拒绝为无效属性),那么它可能是一个错误。在github.com/CommunityToolkit/Maui/issues 添加问题。我还注意到文本没有垂直居中,这似乎是另一个错误。

标签: maui maui-community-toolkit


【解决方案1】:

GitHub issue也有同样的问题,正如回答者所说,这是iOS的正常行为。在 iOS 中,层次结构由视图控制器管理。每个页面都有一个单独的视图控制器。页面由窗口、根视图和子视图组成。将背景色设置为透明,看不到上一页的布局。

更多详细信息,您可以参考以下文档:

User interface | Microsoft

The View Controller Hierarchy | Apple

【讨论】:

    猜你喜欢
    • 2017-04-24
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 2013-06-09
    • 2019-02-09
    • 2013-03-22
    • 1970-01-01
    • 2016-06-21
    相关资源
    最近更新 更多