iOS 13 之前, 去掉黑线:设置UITarBar的 backgroundImage 和 shadowImage即可:
tabbar.backgroundImage = UIImage(color: UIColor.clear)
tabbar.shadowImage = UIImage(color: UIColor.clear)
iOS13之后不好使了,改用下面的方法:
let appearance = tabbar.standardAppearance.copy()
appearance.backgroundImage = UIImage(color: UIColor.clear)
appearance.shadowImage = UIImage(color: UIColor.clear)
tabbar.standardAppearance = appearance
1
所以兼容代码如下:
if #available(iOS 13, *) {
let appearance = tabbar.standardAppearance.copy()
appearance.backgroundImage = UIImage(color: UIColor.clear)
appearance.shadowImage = UIImage(color: UIColor.clear)
tabbar.standardAppearance = appearance
} else {
tabbar.backgroundImage = UIImage(color: UIColor.clear)
tabbar.shadowImage = UIImage(color: UIColor.clear)
}