简体   繁体   English

如何删除 iOS 上显示的标签栏上方的行

[英]How can I remove the line above the tab bar that shows on iOS

Here's what I am trying to remove.这是我要删除的内容。 I thought it was already removed in earlier iOS but now in 13.3 I think it's back again:我认为它已经在早期的 iO​​S 中被删除了,但现在在 13.3 中我认为它又回来了:

在此处输入图片说明

Here is the renderer code I was using before:这是我之前使用的渲染器代码:

    protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
    {
        var renderer = base.CreateShellItemRenderer(item);
        (renderer as ShellItemRenderer).TabBar.Translucent = false;
        (renderer as ShellItemRenderer).TabBar.ShadowImage = new UIImage(); // <<<<<<<
        (renderer as ShellItemRenderer).TabBar.BackgroundImage = new UIImage();
        UITabBar myTabBar = (renderer as ShellItemRenderer).TabBar;

        foreach (var barItem in myTabBar.Items)
        {
            barItem.ImageInsets = new UIEdgeInsets(5, 0, 0, 0);
        }
        return renderer;
    }

The overriden method CreateShellItemRenderer can not get Tabbar now , it will return null .重写方法CreateShellItemRenderer现在无法获取Tabbar ,它将返回null Therefore code can not work .因此代码不能工作。

You can override CreateTabBarAppearanceTracker to get Tabbar in iOS 13 .As follow :您可以覆盖CreateTabBarAppearanceTracker以获取 iOS 13 中的 Tabbar。如下:

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

        public class MyOtherTabBarAppearanceTracker : ShellTabBarAppearanceTracker, IShellTabBarAppearanceTracker
        {
            void IShellTabBarAppearanceTracker.SetAppearance(UITabBarController controller, ShellAppearance appearance)
            {
                base.SetAppearance(controller, appearance);
                var tabBar = controller.TabBar;
                tabBar.BackgroundImage = new UIImage();
                tabBar.ClipsToBounds = true;
                //tabBar.Translucent = false;
            }
        }
    }
}

The effect :效果:

在此处输入图片说明

that's the Home Indicator那是主页指示器

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             ios:Page.PrefersHomeIndicatorAutoHidden="true">
    ...
</ContentPage>

暂无
暂无

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

相关问题 带有外壳的 TabbedPage (FlyoutBehavior=&quot;disabled&quot;) 在 Android 中的选项卡上方显示空白区域,在 iOS 中显示带有页面标题的栏 如何删除它? - TabbedPage with Shell (FlyoutBehavior="disabled") show blank space above tab in Android and bar with Page Title in iOS How to remove it? 如何使用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? 标签栏显示在屏幕外部 - Tab bar shows outside of screen ios标签栏导航 - ios Tab Bar Navigation 如何在iOS和Xamarin中更改导航栏&lt;和单词的颜色? - How can I change the color of the Navigation Bar < and word in iOS and Xamarin? 如何更改Xamarin.Forms标签栏高度(iOS) - How to change Xamarin.Forms Tab Bar height (iOS) 如何使用 Xamarin 在 iOS 上设置 Material Components 选项卡栏的宽度 - How to set width of Material Components tab bar on iOS with Xamarin 如何仅在IOS中启用导航栏并同时禁用Android中的导航栏? - How can i enable navigation bar only in IOS and disable the navigation bar in Android at the same time? 如何制作边框作为仅显示为1px普通线的边框? - How can I make a frame as a border that just shows as a plain 1px line? 如何更改后退按钮的文本并删除选项卡页面上的&lt;箭头? - How can I change the text of a back button and remove the < arrow on a tab page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM