Saty
Saty

Reputation: 2621

Changing Tabbar item title programmatically in viewDidLoad()

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: "");
}

Upvotes: 4

Views: 4952

Answers (1)

Saty
Saty

Reputation: 2621

I did it using the below code in viewdidload()

if let downcastStrings = self.tabBarController?.tabBar.items as? [UITabBarItem]
        {
            downcastStrings[0].title = "Hi"
        }

Upvotes: 7

Related Questions