Is it possible to add a standard-looking badge to a standard UIButton
?
If it's not supported semi-natively, what would be the simplest way to achieve this?
Example image:
Here's a VERY NICE class by Sascha Paulus called CustomBadge, that builds and renders custom badges using Core Graphics. They're just UIView subclasses, so you lay them out using their frame just like any other UIView subclass.
I've used this library many times and always been pleased with the results. Flexible, easy to use. Totally recommend it.
You can check for several options here: CocoaControls Badges
The class that Apple uses is _UIBadgeView
(https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UIBadgeView.h), but of course, this class is private (note the underscore) and not documented.
Here's another class that implements this view with the same look and feel as Apple's while also allowing you to customize it: https://github.com/JaviSoto/JSBadgeView. The great thing about this one is that it lets you position the badge relative to another view automatically, in one of its corners.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With