You can do this by adding a custom image to be created in your code, prior to selectionIndicatorImage on your UITabBar object. For example, you can create an extension class for UIImage as follows:
extension UIImage { func createSelectionIndicator(color: UIColor, size: CGSize, lineWidth: CGFloat) -> UIImage { UIGraphicsBeginImageContextWithOptions(size, false, 0) color.setFill() UIRectFill(CGRectMake(0, size.height - lineWidth, size.width, lineWidth)) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image } }
And name it in the first loaded ViewController as follows:
class FirstViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let tabBar = self.tabBarController!.tabBar tabBar.selectionIndicatorImage = UIImage().createSelectionIndicator(UIColor.blueColor(), size: CGSizeMake(tabBar.frame.width/CGFloat(tabBar.items!.count), tabBar.frame.height), lineWidth: 2.0) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning()
In this case, the result will be like this:

source share