iOS 13 之前, 去掉黑线:设置UITarBar的 backgroundImage 和 shadowImage即可:
self.tabBar.backgroundImage = UIImage.init()
self.tabBar.shadowImage = UIImage.init()
iOS13之后不好使了,改用下面的方法:
if #available(iOS 13, *) {
let appearance = tabBar.standardAppearance.copy()
appearance.backgroundImage = UIImage.imageWithColor(color: .clear)
appearance.shadowImage = UIImage.imageWithColor(color: .clear)
tabBar.standardAppearance = appearance
} else {
tabBar.backgroundImage = UIImage.imageWithColor(color: .clear)
tabBar.shadowImage = UIImage.imageWithColor(color: .clear)
}
UIImage扩展
extension UIImage{
}