1

Please note: this is iOS Swift 2.0

I have added a tabBarItem to my UITabBarController. The image is intentionally larger than the height of the TabBar itself (by design). When this renders on the phone, there is a black line through the image of the tabBarItem.

Here is the code I used to generate the 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)

Here is an image showing the black line:

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

How do I remove the black line through the green icon?

chriswirz
  • 278
  • 1
  • 9

2 Answers2

2

To remove the top shadow of the UITabBar use the following code on the first view controller:

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

Note that this code will remove the shadow line from edge to edge of the screen.

Eneko Alonso
  • 18,884
  • 9
  • 62
  • 84
  • The proposed code removes the background. UITabBar.appearance().backgroundImage = UIImage() And the first line does not remove the border UITabBar.appearance().shadowImage = UIImage() – chriswirz Oct 17 '15 at 04:16
0

Try

checkInViewController.tabBarItem.displayLayer.zPosition = 1000

Your tab bar item will be drawn on top of tabBar's shadow layer.

You will see the shadow other in the tab bar other than the specific tab bar item. Visually it is very appealing.

Jageet Mohan J
  • 115
  • 2
  • 9