查看CustomBadge,该网站是德语,但那里有示例源代码.
您还可以从标签栏视图中窃取徽章,如下所示:
IBOutlet UITabBarItem *tabbarItem;
UIView *badgeView;
Run Code Online (Sandbox Code Playgroud)
badgeView = [[UIView alloc] initWithFrame:CGRectMake(25,100, 32, 32)];
badgeView.backgroundColor = [UIColor clearColor];
badgeView.clipsToBounds = NO;
[badgeView addSubview:[((UIView *)[tabbar.subviews objectAtIndex:0]).subviews objectAtIndex:0]];
Run Code Online (Sandbox Code Playgroud)
并设置该徽章的值:
tabbarItem.badgeValue = unreadCount;
Run Code Online (Sandbox Code Playgroud)
请注意,您不必使用应用程序中可见的UITabbar,您只需窃取徽章资源即可.
| 归档时间: |
|
| 查看次数: |
1225 次 |
| 最近记录: |