thii / FontAwesome.swift

Use FontAwesome in your Swift projects
MIT License
1.57k stars 265 forks source link

Loading Tab Bar Images On Load #44

Closed danwatco closed 9 years ago

danwatco commented 9 years ago

I have a line in each of my view controllers to set the tab bar image. This is fine, but only works once you've clicked the tab. Is there anyway to load the images with the tab bar controller so they are loaded on the tab bar controller load?

danwatco commented 9 years ago

Found it now, if any one is looking. You need to create a custom tab bar controller if you don't already have one and add this code in viewDidLoad().

let first = self.viewControllers?[0]
first?.tabBarItem.image = UIImage.fontAwesomeIconWithName(.ArrowUp, textColor: UIColor.blackColor(), size: CGSizeMake(30, 30))
let second = self.viewControllers?[1]
second?.tabBarItem.image = UIImage.fontAwesomeIconWithName(.ArrowDown, textColor: UIColor.blackColor(), size: CGSizeMake(30, 30))