分系統版本,有點區別
///消除導航欄下劃線
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!
}