Remove UITabBar horizontal separator in iOS7

不羁的心 提交于 2019-12-10 21:28:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!