问题
How can I add a custom UIImage as the Badge for a UITabBarItem?
I.e It will show up when the badge value of the UITabbarItem is set.
回答1:
Consider subclassing UITabBarItem and drawing it yourself
回答2:
Sascha Paulus wrote a great class that does just this:
CustomBadge2.0
You can of course use it in combination with subclassing UITabBarItem
.
回答3:
u can use the following custom class for CustomBadge:
https://github.com/ckteebe/CustomBadge/tree/master/Classes
i hope this will help you.
回答4:
Can have a look inside here. Here custom item is added as a UILabel. Consider using your own choices here.
Demo
and only two line of code, to get you go
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//supplying the animation parameter
[UITabBarItem setDefaultAnimationProvider:[[DefaultTabbarBadgeAnimation alloc] init]];
[UITabBarItem setDefaultConfigurationProvider:[[DefaultSystemLikeBadgeConfiguration alloc] init]];
//rest of your code goes following...
return YES;
}
来源:https://stackoverflow.com/questions/8288656/how-to-use-a-custom-uiimage-as-an-uitabbaritem-badge