Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use iOS's standard red number badges within my app? [closed]

I know that it's trivial to add a red number badge to an app's icon on the home screen. What's the best way to get a badge that looks like this within my app? There are some classes I've found online that can do this, such as MKNumberBadgeView, but none that I've found look completely right. Facebook, for example, implements red badges within the app perfectly as far as I can see. Did they just build their own badges by trial and error? Any suggestions would be appreciated.

Thanks,

Luke

like image 595
Luke Avatar asked Oct 10 '10 00:10

Luke


3 Answers

Where do you want the badge? The standard badge can trivially be added to a UITabBarItem through the badgeValue property. It is documented here.

like image 109
Sedate Alien Avatar answered Oct 13 '22 01:10

Sedate Alien


I am using this by Sascha Paulus - http://www.spaulus.com/2011/04/custombadge-2-0-retina-ready-scalable-light-reflex/?lang=en

Which is a class that you can drop into your project, easy enough to customize for the appearance you are looking for. I had a slight issue with the placement of the number within the red badge so I shifted it slightly. Other than that, all good.

like image 37
Kwok Pan Fung Avatar answered Oct 13 '22 02:10

Kwok Pan Fung


This one looks 100% like the Apple one and it's also completely customizable: https://github.com/JaviSoto/JSBadgeView

like image 5
Javier Soto Avatar answered Oct 13 '22 01:10

Javier Soto