问题
I want to remove the horizontal separator line between a UITabBar and the rest of the screen. I'm asking the same question as this guy but updated for iOS7.
Setting the background image of my UITabBar doesn't alleviate the problem, nor does setting the background image of the [UITabBar appearance]
object.
Is this still possible in iOS7? If so, how?
回答1:
The answer to this is pretty much the same as removing the separator of a navigation bar or a toolbar.
Officially, this is only possible by setting the shadowImage to an empty image. However, a closer look at the documentation, we see that:
For a custom shadow image to be shown, a custom background image must also be set using the backgroundImage property. If the default background image is used, then the default shadow image will be used regardless of the value of this property.
By using a custom background image, you would lose the blurred background translucency.
The separator is a UIImageView that is a subview of the tab bar. You can find it in the tab bar's hierarchy and set it to hidden.
回答2:
You could also hide shadow line using this code:
[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];
Swift
self.tabBar.setValue(true, forKey: "_hidesShadow")
回答3:
tabBar.shadowImage = [UIImage new];
uses a transparent image, so it is more preferable.
In Swift,tabBar.shadowImage = UIImage()
来源:https://stackoverflow.com/questions/23145216/remove-uitabbar-horizontal-separator-in-ios7