iOS 10: Custom UITabBar background image produces border at top of image. How do I remove it?

戏子无情 提交于 2019-12-04 07:23:52

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)

It work for me

This was happening to me because my image was taller than the default tab bar of 49. Making sure my background image height was exactly 49 made this line disappear (96 for 2x and 147 for 3x).

Hope it helps!

Try this:

tabBar.layer.borderWidth = 0
tabBar.layer.borderColor = .clear

Are you sure there is no border in the image itself?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!