【问题标题】:Xamarin Forms Shell - iOS extend view under bottom TabBarXamarin Forms Shell - iOS 在底部 TabBar 下扩展视图
【发布时间】:2021-08-10 14:59:32
【问题描述】:

我正在尝试从 iOS 底部标签栏下的 Shell 扩展我的页面

MyShellRenderer:ShellRenderer

[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
 namespace your namepace
 {
   class MyShellRenderer:ShellRenderer
   {
      protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
      {
          return new MyShellTabBarAppearanceTrancker();
      }
   }
 }

MyShellTabBarAppearanceTrancker 类:

class MyShellTabBarAppearanceTrancker : IShellTabBarAppearanceTracker
{
    public void Dispose()
    {

    }

    public void ResetAppearance(UITabBarController controller)
    {
      
    }

    public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
    {
       controller.TabBar.IsTranslucent = true;        
    }

    public void UpdateLayout(UITabBarController controller)
    {
        
    }
}

但它不起作用,Shell 将所有页面保留在底部标签栏上方(就像在堆栈布局中一样)。

【问题讨论】:

    标签: xamarin.forms xamarin.ios xamarin-forms-shell


    【解决方案1】:

    使用Alpha 代替IsTranslucent

    此属性的值是一个介于 0.0 到 1.0 之间的浮点数,其中 0.0 表示完全透明,1.0 表示完全不透明。

    尝试设置为controller.TabBar.Alpha = 0.5f;

    xaml 中的测试代码

       <Grid>
            <Label Text="111" VerticalOptions="Start"/>
            <Label Text="222" Margin="30,0,0,-50" VerticalOptions="End"/>
        </Grid>
    

    【讨论】:

    • idk 怎么做,但它对我不起作用:/ 是否可以在渲染器中完成此操作而无需设置透明度?
    • 无需设置透明度?这是什么意思?
    • 不透明栏(纯色),我解释了为什么要实现这一点:因为我在标签栏上添加了圆角(左上角和右上角),但视图位于标签栏上方,所以渲染不好,解决方案是视图应该在标签栏下通过
    猜你喜欢
    • 2021-04-23
    • 2019-11-06
    • 2021-12-09
    • 2021-05-16
    • 2020-04-28
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 2021-02-07
    相关资源
    最近更新 更多