How can I add a badge to a standard UIButton?

ohadpr picture ohadpr · Jan 18, 2011 · Viewed 54.4k times · Source

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:

An iPhone UI button

Answer

Dan Ray picture Dan Ray · Jan 18, 2011

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.