0

I've been trying to remove the top border (shadow) line from Tab Bar in Swift 4 for > iOS 10. I'm also using a custom background image. I've just given up after searching for solutions, since none of them work.

The solution which came closest was this post.

The solution given everywhere works if there is no background or for < iOS 10. For iOS > 10 and using a custom background image none of solutions work.

I even tried using a transparent shadow image, but it required setting cliptobounds to true which doesn't show custom background image.

So at the end of all these solution I'm stuck. Couldn't find any working solution.

I'm setting these custom values in AppDelegate so that it works for all Tab Bars.

halfer
  • 19,824
  • 17
  • 99
  • 186
Matt
  • 315
  • 2
  • 6
  • 20

1 Answers1

3

I just created a sample project using tab bar template from Xcode and write three lines of code

self.tabBar.layer.borderWidth = 0
self.tabBar.clipsToBounds = true
self.tabBar.backgroundColor = .blue

And tab bar top border is no longer visible. I've tested this on Simulator iphone 6 with ios 11.2

enter image description here

Sahil Manchanda
  • 9,812
  • 4
  • 39
  • 89
  • Humm!!! Weird I did try this solution before but didn't work. Now it works. – Matt May 15 '18 at 17:29
  • 1
    Thanks. I'm adding code in AppDelegate, following is the working code: UITabBar.appearance().layer.borderWidth = 0.0 UITabBar.appearance().clipsToBounds = true – Matt May 15 '18 at 17:31