3

Hello All i am creating Tab bar programmatically, in my functionality there need to be selected tab filled with custom color, i have achieved this so far using below code and the following output see screenshot.

tabBarController.tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: colors.AppSkyBlue, size: tabBarItemSize).resizableImage(withCapInsets: UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1), resizingMode: .stretch)

enter image description here

Clearly see the white space be around selected tab, ho do i remove this from all side. Any help would be appreciated well.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
vaibhav
  • 4,038
  • 1
  • 21
  • 51
  • How about adding a subview on top of your tabbar, with background color same as tabbar color, so it blends with it., written a simple code snippet for the same. – Srikanth Balaji Aug 30 '19 at 06:04
  • see this : https://stackoverflow.com/questions/33868139/how-to-make-uitabbar-selection-indicator-image-fill-the-whole-space/34510070#34510070 – Piyush Aug 30 '19 at 06:37

1 Answers1

1

You Could simple add a subview on top of UITabBar and give the bg color same as the color of tab bar - so it blends with it

var lineView = UIView(frame: CGRect(x: 0, y: 0, width:tabBarController.tabBar.frame.size.width, height: 1))
lineView.backgroundColor = UIColor.grey
tabBarController.tabBar.addSubview(lineView)

This is one of the options.

Srikanth Balaji
  • 2,638
  • 4
  • 18
  • 31