5

I'm pretty new to MonoTouch development, but I've been using the handy ToolbarItems property on the UIViewController to show some toolbar buttons and now I'm looking for a way to set the BadgeValue on some of those buttons.

It seems that the UIBarButtonItem class is missing the BadgeValue property you see on UITabBarItem, so the question is - how to set the badge value for a UIBarButtonItem in the ToolbarItems collection ?

UIBarButtonItem item1 = new UIBarButtonItem() { Title = "test" };
//item1.BadgeValue = "3"; //this doesn't work
ToolbarItems = new UIBarButtonItem[] { item1 };
Johan Danforth
  • 4,469
  • 6
  • 37
  • 36

1 Answers1

1

Both UIBarButtonItem and UITabBarItem inherit from UIBarItem. Sadly BadgeValue is only available for UITabBarItem so you'll need to reimplement this feature yourself.

This question (and answer) should help you: How to add Badges on UIBarbutton item?

But be warned that it might now look as good as a real badge.

Community
  • 1
  • 1
poupou
  • 43,413
  • 6
  • 77
  • 174
  • Awww, so sad, I was afraid I was going to get that answer :/ I guess I have to use a view controller inside tab bar controller then. – Johan Danforth Aug 21 '12 at 12:39