Reputation: 278
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?
Upvotes: 1
Views: 1287
Reputation: 115
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.
Upvotes: 0
Reputation: 19662
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.
Upvotes: 2