Set BadgeValue for ToolbarItems.UIBarButtonItem in MonoTouch

I'm new to MonoTouch, but I used the convenient ToolbarItems property on the UIViewController to show some buttons on the toolbar, and now I'm looking for a way to set BadgeValue on some of these buttons.

It seems that the UIBarButtonItem property that you see on UITabBarItem from the UITabBarItem , so the question is: how to set the icon value for UIBarButtonItem in the ToolbarItems collection?

 UIBarButtonItem item1 = new UIBarButtonItem() { Title = "test" }; //item1.BadgeValue = "3"; //this doesn't work ToolbarItems = new UIBarButtonItem[] { item1 }; 
+4
source share
1 answer

Both UIBarButtonItem and UITabBarItem inherit from UIBarItem . Unfortunately, BadgeValue is only available for UITabBarItem , so you need to override this function yourself.

This question (and answer) should help you: How to add icons to a UIBarbutton element?

But be careful that it now looks as good as a real badge.

0
source

All Articles