How to set a badge value on a UITabBarController item

Screen Shot 2014-04-21 at 08.53.48

Each view controller has access to a UITabBarItem. This is only displayed if the current view controller is part of a UITabBarController. A UITabBarItem has a badge value which is that little red mark above icon and name to the tab bar item itself (as shown in the screenshot above: LIVE is currently the badgeValue of the tab bar item).

Here’s how you can set the badge value:

This approach will work if you have direct access to the class in the view controller. More commonly though you’ll have your own class embedded in a UINavigationController, in which case its tab bar item (and title) is shown on that tab.

In which case you can access the tab bar item like this:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.