繁体   English   中英

如何使用iOS渲染器在Xamarin Forms Shell应用程序的底部标签栏中添加背景图像?

[英]How can I add a background image to the bottom tab bar in a Xamarin Forms Shell application with an iOS renderer?

我知道如何在顶部标题区域执行此操作:

    protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
    {
        var renderer = base.CreateShellSectionRenderer(shellSection);
        if (renderer != null)
        {
            (renderer as ShellSectionRenderer).NavigationBar.SetBackgroundImage(UIImage.FromFile("LaunchIcon.png"), UIBarMetrics.Default);

        }
        return renderer;
    }

但不在底部导航标签区域中。

将感谢尝试自定义底部区域背景的任何人的任何建议。

在IOS ShellRenderer中 ,您可以覆盖IShellTabBarAppearanceTracker以将背景图像设置为TabBar。

protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
    return new MyOtherShellTabBarAppearanceTracker();
}

void IShellTabBarAppearanceTracker.SetAppearance(UITabBarController controller, ShellAppearance appearance)
    {
        base.SetAppearance(controller,appearance);
        var tabBar = controller.TabBar;
        UIImage image = UIImage.FromFile("TabBackground.png"); // tab bar background image
        tabBar.BackgroundImage = image;
        tabBar.ClipsToBounds = true;// if needed. If image is larger than the tab bar, the tab bar will expand to the image size. With this the image will be clipped to the tab bar size.
    }
}

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM