IOS工具栏上的图标颜色仍为蓝色xamarin.forms

时间:2017-08-18 08:38:05

标签: c# xaml xamarin.forms

我在Toolbar上使用了红色图标,但它仍然保持蓝色,就像默认情况一样。如何将其更改为红色。 因为最初图标的颜色最初是红色的。 我怎么能解决这个问题。

以下是图片:

enter image description here

,这是Xaml代码:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    Icon ="nav_icon.png"    Title="Ea "

    x:Class="EAMobileDirectory.MasterPage">

    <StackLayout>
        <Image   Source="featured_newline_1.png"  Margin="0,1,0,0"/>
        <ListView x:Name="listView"   Margin="0,10,0,0" VerticalOptions="FillAndExpand" SeparatorVisibility="None">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ImageCell Text="{Binding Title}" ImageSource="{Binding IconSource}" />
                    </DataTemplate>
                </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage>

我还更改了我的AppDelegate.cs文件根据@Steven,下面是我更改的代码:

[Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            LoadApplication(new App());
            UIToolbar.Appearance.TintColor = UIColor.Red;
            UIToolbar.Appearance.BarTintColor = UIColor.Green;

            return base.FinishedLaunching(app, options);
        }
    }

1 个答案:

答案 0 :(得分:7)

这是由于TintColor属性在iOS上接管。它使您能够以所需的每种颜色提供图像,并使用TintColor可以为任何颜色着色。要更改此设置,请尝试在AppDelegate.cs中添加以下内容:

UINavigationBar.Appearance.TintColor = UIColor.Red;

这将为应用程序中每个UINavigationBar的图标设置样式。