4

I am trying to change the title of the tab item through the below code where I have to write that code in awakeFormNib() however due to some circumstances, I have to change the title in viewdidLoad(). I am using Swift.

override func awakeFromNib() {
    self.title = NSLocalizedString("Hello World", tableName: "xxx", comment: "");
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Saty
  • 2,563
  • 3
  • 37
  • 88
  • I know there is a self.tabBarController?.tabBar.items which is [Anyobject] how to access each item – Saty Jul 06 '15 at 12:10

1 Answers1

7

I did it using the below code in viewdidload()

if let downcastStrings = self.tabBarController?.tabBar.items as? [UITabBarItem]
        {
            downcastStrings[0].title = "Hi"
        }
Saty
  • 2,563
  • 3
  • 37
  • 88