繁体   English   中英

如何向 Xamarin Forms App Shell Tabbar 添加顶部边框

[英]How to add a top border to Xamarin Forms App Shell Tabbar

使用 Xamarin Forms App Shell 模板,很明显如何更改 Tabbar 的背景颜色,但我看不到添加顶部边框甚至阴影的方法,这在许多选项卡栏样式中很常见。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

安卓:

您可以使用CreateBottomNavViewAppearanceTracker为底部视图更改某些内容。

  [assembly: ExportRenderer(typeof(AppShell), typeof(ShellCustomRenderer))]
namespace ShellDemo.Droid
{
class ShellCustomRenderer : ShellRenderer
{

    public ShellCustomRenderer(Context context) : base(context)
    {
    }

    protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
    {
        return new CustomBottomNavAppearance();
    }
}

public class CustomBottomNavAppearance : IShellBottomNavViewAppearanceTracker
{
    public void Dispose()
    {

    }

    public void ResetAppearance(BottomNavigationView bottomView)
    {

    }

    public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
    {
        //put your code here
       
    }
}
}

IOS:

您可以使用CreateTabBarAppearanceTracker来更改标签栏。

  [assembly: ExportRenderer(typeof(AppShell), typeof(ShellCustomRenderer))]
namespace ShellDemo.iOS
{
public class ShellCustomRenderer : ShellRenderer
{
    protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
    {
        return new TabBarAppearance();
    }

}

public class TabBarAppearance : IShellTabBarAppearanceTracker
{
    public void Dispose()
    {

    }

    public void ResetAppearance(UITabBarController controller)
    {
        
    }

    public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
    {
    }

    public void UpdateLayout(UITabBarController controller)
    {
    }
}
}

暂无
暂无

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

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