【问题标题】:Change the BackgroundColor of Xamarin.Forms Shell top TabBar (without changing the NavigationbarColor)更改 Xamarin.Forms Shell 顶部 TabBar 的 BackgroundColor(不更改 NavigationbarColor)
【发布时间】:2020-10-28 22:27:49
【问题描述】:

可以通过设置“Shell.BackgroundColor”来更改顶部的 TabBars BackgroundColor。但这也会改变 NavigationBar 的 BackgroundColor(绿色区域)。

有谁知道如何在不更改 NavigationBar 的 BackgroundColor 的情况下更改顶部 TabBar 的 BackgroundColor?

还有什么奇怪的。通过设置“Shell.BackgroundColor”,两种颜色都将被设置(Shell 顶部 TabBar 和 NavigationBar),但它们的颜色略有不同。有谁知道为什么?

【问题讨论】:

  • 好像已经有 GitHub 问题了

标签: shell colors background tabbar xamarin.forms.shell


【解决方案1】:

似乎已经有一个 GitHub 问题 https://github.com/xamarin/Xamarin.Forms/issues/6711

希望对你有帮助

public class CustomShellRenderer : ShellRenderer
{
    protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
    {
        var renderer = base.CreateShellSectionRenderer(shellSection);
        if (renderer != null)
        {
            var a = (renderer as ShellSectionRenderer);
            (renderer as ShellSectionRenderer).NavigationBar.Translucent = false;
        }
        return renderer;
    }

    protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
    {
        var renderer = base.CreateShellItemRenderer(item);
        (renderer as ShellItemRenderer).TabBar.Translucent = false;
        return renderer;
    }
}

或者将 Shell.BackgroundColor 设置为空值 -> Shell.BackgroundColor=""

【讨论】:

    猜你喜欢
    • 2021-08-22
    • 1970-01-01
    • 2017-10-29
    • 2021-03-19
    • 1970-01-01
    • 2020-04-28
    • 2019-02-11
    • 2019-09-09
    • 1970-01-01
    相关资源
    最近更新 更多