Введите код в AppDelegate
didFinishLaunching
метод: -
let tabBarController = self.window!.rootViewController as! UITabBarController
let tabBar = tabBarController.tabBar
DispatchQueue.main.async {
tabBar.selectionIndicatorImage = UIImage().createSelectionIndicatorFill(fillColor:.red, lineColor:.blue,size: CGSize(width:tabBar.frame.width/CGFloat(tabBar.items!.count), height:tabBar.frame.height), lineWidth: 1.0)
tabBar.unselectedItemTintColor = customColor
}
и сделайте расширение UIImage
extension UIImage {
func createSelectionIndicatorFill(fillColor: UIColor,lineColor:UIColor,size: CGSize, lineWidth: CGFloat) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
fillColor.setFill()
UIRectFill(CGRect(x:0, y:0, width:size.width, height:size.height - lineWidth))
lineColor.setFill()
UIRectFill(CGRect(x:0, y:size.height - lineWidth, width:size.width, height:lineWidth))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}