1

I'm working on customising my TabBarItems. I've changed the height of the TabBar to what I want by doing so:

override func viewWillLayoutSubviews() {
    var tabFrame = self.tabBar.frame
    tabFrame.size.height =  60
    tabFrame.origin.y = self.view.frame.size.height - 60
    self.tabBar.frame = tabFrame
}

I would like to have a white background on my TabBarItems, as shown below.

enter image description here

However I'm pretty lost how to do it, and if it's possible?

Recusiwe
  • 1,594
  • 4
  • 31
  • 54

1 Answers1

0

Hi I wrote this in swift 3, you can add this in the appDelegate file

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let tabBarController = window?.rootViewController as! UITabBarController
    let image = UIImage(named: "itemBar")

    tabBarController.tabBar.backgroundColor = UIColor.white() // 1
    tabBarController.tabBar.items?[0].selectedImage = image  // 2

    return true
}

(1) you set the background colour of tabBar

(2) you can set the selected image ( you can create an image with those black borders), you might want to add a different image for each different item but this is a basic example of how to do it with one item.

Good luck