I tried to subclass the UITabBar and applied a Gradient color but the code i used added the color to the whole tab bar section
Code Used:
class TabViewController : UITabBarController {
let gradientlayer = CAGradientLayer()
override func viewDidLoad() {
super.viewDidLoad()
}
func setUpSelectionIndicatorImage(withColors colors: [UIColor]) {
gradientlayer.frame = tabBar.bounds
gradientlayer.colors = [colors[0].cgColor, colors[1].cgColor]
gradientlayer.locations = [0, 1]
gradientlayer.startPoint = CGPoint(x: 1.0, y: 0.0)
gradientlayer.endPoint = CGPoint(x: 0.0, y: 0.0)
self.tabBar.layer.insertSublayer(gradientlayer, at: 0)
}
override func viewDidLayoutSubviews() {
super.viewWillLayoutSubviews()
let colors = [UIColor.IntroGradientColor1 , UIColor.IntroGradientColor2]
setUpSelectionIndicatorImage(withColors: colors)
}
}
Any idea how can i achieve this blue Gradient color ONLY on the selected tab like in the image attached .