Reputation: 830
I have a UITabBarController
implemented in my project. I am working on it and it was working as expected. Now before asking my question let me tell you how many tab bar items I have. The following are the tab bar items I have in my app:
Now when I click on Main List it opens respective ViewController
. And it happens for all other tabs as well.
But now in first tab (View controller) I have to perform some operations which needs to update the text or title of tab bar 2, tab bar 3, and tab bar 4.
For example, after performing some operations I want my tab bar title in following manner
I hope you got my point. I have seen badges in some apps, but I really do not want that. If there is any idea or link. I am using Swift 4.
Upvotes: 1
Views: 428
Reputation: 51
I hope this will work for you.
You can fetch TabBarController from your viewController which is located in any tab.
you need to paste this code in any of your viewController and you can find all tabBar items. Now you need to identify tabBar item and update accordingly.
let tabVC = self.tabBarController
if let items = tabVC?.tabBar.items {
for item in items {
item.title = "Your Title"
}
}
Upvotes: 1