【问题标题】:Xamarin iOS - Tab Page - Move Icon PostitionsXamarin iOS - 标签页 - 移动图标位置
【发布时间】:2021-02-24 18:12:49
【问题描述】:

我的应用中有一个标签页,在 android 上它看起来很棒 - 输入了图标(没有文字,只有图标)并且看起来不错。

在 iOS 上,我的标签栏位于底部(这很好),但图标被向右按到标签栏的顶部。因此,它们下方有大量空间,但它们位于顶部的边缘。好吧,其中至少有 2 个是。由于图像设计,另外两个内置了几个像素的图像填充,并且触摸较低。但这不是重点。

如何仅在 iOS 上为标签页图标设置一些填充?还是居中?

【问题讨论】:

  • 我的解决方案对您有用吗?如果是,请您接受(点击此答案左上角的☑️),以便我们可以帮助更多有相同问题的人:)。

标签: xamarin xamarin.ios icons


【解决方案1】:

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

[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);

        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多