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

随声附和 提交于 2019-12-03 04:35:08

问题


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


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/3898510/how-can-i-use-ioss-standard-red-number-badges-within-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!