分系统版本,有点区别
///消除导航栏下划线
func clearNavigationBarLine() {
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
}
///消除标签栏下划线
func clearTabBarLine() {
let image_w = creatColorImage(.white)
if #available(iOS 13.0, *) {
let appearance = UITabBarAppearance()
appearance.backgroundImage = image_w
appearance.shadowImage = image_w
self.tabBarController?.tabBar.standardAppearance = appearance
} else {
self.tabBarController?.tabBar.backgroundImage = image_w
self.tabBarController?.tabBar.shadowImage = image_w
}
}
///用颜色创建一张图片
func creatColorImage(_ color:UIColor,_ ARect:CGRect = CGRect.init(x: 0, y: 0, width: 1, height: 1)) -> UIImage {
let rect = ARect
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(color.cgColor)
context?.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
网友评论