Show Apple Alert Badge In APP Without APNS
-
26-05-2021 - |
Domanda
I have a main menu in my monotouch app that has 4 icons which go to various other screens. I would like to put an alert badge on one of the icons when my alert criteria has been met. Is there a way to do this using applicationIconBadgeNumber or something similar?
Soluzione
If you mean a UITabBarController
than this code will do what you need
viewController.tabBarItem.badgeValue = 1;
Where the viewcontroller
is the UIViewController which is associated with the tab]
If you would like to add it to a UIButton
you can use this class here
That should allow you do it.
Altri suggerimenti
You can't add badges to arbitrary buttons or views. You could manage it yourself. You could create the badge as an image and draw it outside your buttons bounds, at the location you want it to appear. You'll want to make sure clipToBounds is set to NO
so it shows.