开发者

iPhone: add badge to icons internal to my app

I am trying to add badges to the icons in my app. e.g. in the facebook app, in the home page the number of pending requests is shown on the reques开发者_开发知识库ts icon.

Can someone provide any links/ideas on how to do this?

Thanks, V


I know this article is a little bit old, but it helps me recently to make a little class to create custom badges. I thought it would be fair to make this class public for everyone. So here it is CustomBadge.

best regard - Sascha


Lots of ways to do this. You can overlay a UILabel over the icon (which may be a UIView or UIImageView). YOu can put another view on top of the icon, and draw the text right into that view. Or make your icon view be a subclass of UIView, and when you get called to draw, you draw the icon and the number.

Plus, you may want to play with blend modes, shadow, masking, etc., in order to create something that is visually attractive.

I'd probably start with reading more about Quartz, if you haven't already. The rest is just how you wire it all up.

And some other links:

http://scientificninja.com/development/numeric-badges-on-the-iphone http://th30z.netsons.org/2009/03/qt4-drawing-notification-badges/ alt text http://th30z.netsons.org/wp-content/uploads/qtdrawbadges.png


The Three20 project (its code is part of the Facebook app) has those badges.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜