【问题标题】:Setting background on IOS在 IOS 上设置背景
【发布时间】:2019-09-03 14:53:58
【问题描述】:

带有主从模板。 我在 app.xaml 上设置颜色 在安卓上运行良好。但无论我做什么,都会在 iO 上保持白色背景。

安卓: https://prnt.sc/p19j24

iOS: https://prnt.sc/p19pse

尝试在单个页面的 xaml 上设置背景。

尝试在代码后面设置背景。

app.xaml

            <Color x:Key="NavigationPrimary">#007DC6</Color>
            <Color x:Key="NavigationBackground">#E4EBF1</Color>
            <Color x:Key="NavigationBackgroundShadow">#D8E1E6</Color>
            <Style TargetType="NavigationPage">
                <Setter Property="BarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="BarTextColor" Value="White" />
                <Setter Property="BackgroundColor" Value="{StaticResource NavigationBackground}" />
            </Style>

about.xaml - 框架


                <Frame BackgroundColor="{StaticResource NavigationBackgroundShadow}"
                       CornerRadius="10"
                       Margin="0,5"
                       x:Name="FrmDistribuidora"
                       IsClippedToBounds="True"
                       Padding="5"
                       HeightRequest="60"
                       BorderColor="#999999">
                    <Label Text="Test" VerticalOptions="Center" HorizontalOptions="Center"/>
                </Frame>

重现代码...

• 使用 android 和 IOS 以及 Master-Detail 模板创建一个新的 xamarin 项目。

• 粘贴 app.xaml 资源。

• 将框架代码粘贴到 about.xaml

【问题讨论】:

    标签: c# ios xaml xamarin.forms


    【解决方案1】:

    您可以设置页面的背景颜色,它适用于 iOS:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
                 BackgroundColor="Yellow"
                 x:Class="aaTest.Views.AboutPage"
                 xmlns:vm="clr-namespace:aaTest.ViewModels"
                 Title="{Binding Title}">
    

    【讨论】:

    • 确实有效。即使在 app.xaml 上放置 也不起作用......为什么只适用于android? xamarin 一直让我失望
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 1970-01-01
    • 2013-07-21
    • 2013-12-30
    • 1970-01-01
    • 1970-01-01
    • 2023-02-20
    相关资源
    最近更新 更多