【问题标题】:iOS Swift tabBarItem intersects tabBar borderiOS Swift tabBarItem 与 tabBar 边框相交
【发布时间】:2015-10-16 03:37:20
【问题描述】:

请注意:这是 iOS Swift 2.0

我已将 tabBarItem 添加到我的 UITabBarController。图像故意大于 TabBar 本身的高度(按设计)。当它在手机上渲染时,tabBarItem 的图像中有一条黑线。

这是我用来生成 tabBarItem 的代码:

let checkInstoryboard = UIStoryboard(name: "CheckIn", bundle: nil)
let checkInViewController = checkInstoryboard.instantiateInitialViewController() as! UINavigationController
checkInViewController.tabBarItem.image = UIImage(named:"check_icon_unselected_vector")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
checkInViewController.tabBarItem.selectedImage = UIImage(named:"check_icon_selected_vector")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

这是显示黑线的图像:

I would like to remove the black line through the green icon

如何通过绿色图标去除黑线?

【问题讨论】:

    标签: swift tabbar uitabbaritem


    【解决方案1】:

    要移除UITabBar 的顶部阴影,请在第一个视图控制器上使用以下代码:

        UITabBar.appearance().shadowImage = UIImage()
        UITabBar.appearance().backgroundImage = UIImage()
    

    请注意,此代码将删除屏幕边缘到边缘的阴影线。

    【讨论】:

    • 建议的代码移除背景。 UITabBar.appearance().backgroundImage = UIImage() 并且第一行不去掉边框 UITabBar.appearance().shadowImage = UIImage()
    【解决方案2】:

    试试

    checkInViewController.tabBarItem.displayLayer.zPosition = 1000
    

    您的标签栏项目将被绘制在 tabBar 的阴影层之上。

    您将在标签栏中看到除特定标签栏项目之外的其他阴影。视觉上非常吸引人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-25
      • 1970-01-01
      相关资源
      最近更新 更多