tags:

views:

276

answers:

3

Hey,

I am wanting to display a number on top of an icon when a user receives a new message, similar to the mail app and sms app when new messages are received (the red number on top of the icon) (btw i want to do it inside my app not on the icon on the home screen)... I know i can just have a little image with every number and draw it on top of an icon or button, but i was wondering if there was any built in API that can do this already?

Thanks

Daniel

+2  A: 

It depends on what interface element you're using. If you're using a tab tab (UITabBar) you'll find that UITabBarItems have a badgeValue property that you can set to some text to display in a red circle as you describe. Unfortunately you might have to do it "by hand" if you're using a different element.

Stephen Darlington
cool i actually wanted to do i t on a tab bar icon...thanks a lot!
Daniel
+1  A: 

This explains the api to add application badges

ennuikiller
A: 

This little bit of code may be easier:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:theIntToDisplay];
Jack Cox
what does this display the badge on?
Daniel
This will set the badge on the application icon (in spring board, ie. outside your app), like the Mail app does for unread messages.
Daniel Rinser