Jonesie
Jonesie

Reputation: 132

Unable to set Tab Bar Badge value on Refactored Storyboard

I refactored my storyboard and now I'm unable to set the badge value on the refactored storyboard.

This is the main story board and MessageCenter is the refactored storyboard.

enter image description here

Message Center StoryBoard:

enter image description here

I'm setting the badge value in the app delegate, which isn't working:

if let tabBarController = self.window!.rootViewController as? UITabBarController { tabBarController.tabBar.items!2.badgeValue = "3" }

Any ideas?

Upvotes: 0

Views: 670

Answers (2)

DiegoQ
DiegoQ

Reputation: 1116

Try with this code in your TabBarCustomViewController:

DispatchQueue.main.async(execute: {
                self.tabBar.items?[3].badgeValue = "3"
})

Upvotes: 1

Dejan Agostini
Dejan Agostini

Reputation: 96

if let tabBarController = self.window?.rootViewController as? UITabBarController { tabBarController.viewControllers?[2].tabBarItem.badgeValue = "3" }

Upvotes: 0

Related Questions