Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: "");
}
like image 542
Saty Avatar asked Mar 16 '23 12:03

Saty


1 Answers

I did it using the below code in viewdidload()

if let downcastStrings = self.tabBarController?.tabBar.items as? [UITabBarItem]
        {
            downcastStrings[0].title = "Hi"
        }
like image 81
Saty Avatar answered May 07 '23 07:05

Saty