iOS 10:自定义UITabBar背景图像在图像顶部产生边框.如何将其删除? [英] iOS 10: Custom UITabBar background image produces border at top of image. How do I remove it?

查看:35
本文介绍了iOS 10:自定义UITabBar背景图像在图像顶部产生边框.如何将其删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人有可行的解决方案来摆脱iOS 10中的边界吗?我有一个自定义的UITabBar背景图片.

Anyone have a working solution to get rid of this border in iOS 10? I have a custom UITabBar background image.

我尝试了以下操作,但没有结果:

I've tried the following with no results:

tabBar.backgroundImage = UIImage(named: "myBackgroundImage.png")
tabBar.shadowImage = nil
tabBar.shadowImage = UIImage()
// i've also tried combinations of this in the storyboard directly

我终于举起了双手,将条形设置为黑色".这不会摆脱边界,但会使其变成白色.因此将其隐藏.

I finally threw my hands up in the air and set the bar style to "Black".. this doesn't get rid of the border, but makes it white. So it hides it.

推荐答案

如果使用backgroundImage,则阴影线会出现因此您可以尝试以下方法:

If you use backgroundImage then shadow line will come so you can try this :

self.tabBar.backgroundImage = UIImage()
self.tabBar.shadowImage = UIImage()
let tabBarView = UIImageView(image: #imageLiteral(resourceName: "YOUR_IMAGE"))
tabBarView.frame = CGRect(x: 0, y: 49 - IMAGEHEIGHT, width: SCREENWIDTH, height: IMAGEHEIGHT)
self.tabBar.addSubview(tabBarView)
self.tabBar.sendSubview(toBack: tabBarView)

对我有用

这篇关于iOS 10:自定义UITabBar背景图像在图像顶部产生边框.如何将其删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆