IOS 10: Custom Background Image UITabBar creates a border above the image. How to remove it?

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

I tried the following without any 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 raised my hands up and set the style to Black. This does not eliminate the border, but makes it white. Therefore, he hides it.

thin border on top

+6
source share
5 answers

If you use backgroundImage then a shadow line will appear so you can try the following:

 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 works for me

+4
source

Try the following:

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

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

0
source

This happened to me because my image was taller than the default tab bar of 49. After making sure the background image was exactly 49, this line disappeared (96 for 2x and 147 for 3x).

Hope this helps!

0
source

because your image height is over 49pt

0
source

Source: https://habr.com/ru/post/1262309/


All Articles