Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin iOS-选项卡页面-移动图标位置_Xamarin_Xamarin.ios_Icons - Fatal编程技术网

Xamarin iOS-选项卡页面-移动图标位置

Xamarin iOS-选项卡页面-移动图标位置,xamarin,xamarin.ios,icons,Xamarin,Xamarin.ios,Icons,我在我的应用程序中有一个标签页,在android上它看起来很棒-输入图标(没有文本,只有图标)看起来很漂亮 在iOS上,我的标签栏位于底部(这很好),但图标被压在标签栏的顶部。所以它们下面有很多空间,但是它们在顶部的边缘。至少有两个是。由于图像设计的原因,另外两款手机内置了几个像素的图像填充,而且价格较低。但这不是重点 如何仅在iOS上设置选项卡页面图标上的一些填充?还是把它们放在中间 您可以使用自定义渲染器将图标居中 [assembly: ExportRenderer(typeof(Tabbe

我在我的应用程序中有一个标签页,在android上它看起来很棒-输入图标(没有文本,只有图标)看起来很漂亮

在iOS上,我的标签栏位于底部(这很好),但图标被压在标签栏的顶部。所以它们下面有很多空间,但是它们在顶部的边缘。至少有两个是。由于图像设计的原因,另外两款手机内置了几个像素的图像填充,而且价格较低。但这不是重点

如何仅在iOS上设置选项卡页面图标上的一些填充?还是把它们放在中间


您可以使用自定义渲染器将图标居中

[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedPageRenderer))]
namespace TabbedPageWithNavigationPage.iOS
{
    class CustomTabbedPageRenderer : TabbedRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
        }

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var tabBarItems = TabBar.Items;
            tabBarItems[0].ImageInsets = new UIEdgeInsets(6, 0, -6, 0);

            tabBarItems[1].ImageInsets = new UIEdgeInsets(6, 0, -6, 0);
            tabBarItems[2].ImageInsets = new UIEdgeInsets(6, 0, -6, 0);

        }
    }
}

我的解决方案对你有用吗?如果是,请您接受(单击☑️ 在这个答案的左上角),这样我们就可以帮助更多有同样问题的人:)。