23
A
回答
59
的Xcode 7.2.1斯威夫特2.1.1
你只需要设置badgeValue您所需的UITabBarItem如下:
tabBarController?.tabBar.items?[4].badgeValue = "1" // this will add "1" badge to your fifth tab bar item
// or like this to apply it to your first tab
tabBarController?.tabBar.items?.first?.badgeValue = "1st"
// or to apply to your second tab
tabBarController?.tabBar.items?[1].badgeValue = "2nd"
// to apply it to your last tab
tabBarController?.tabBar.items?.last?.badgeValue = "Last"
要删除一个徽章从UITabBarItem只需添加零值它
tabBarController?.tabBar.items?.first?.badgeValue = nil
+0
为什么我的tabBarController是零? –
+5
找到了答案。因为我已经在UITabBarController中,所以我不得不从上面的代码中省略tabBarController。 –
相关问题
- 1. 调整UITabBarItem徽章位置?
- 2. 在UIViewController中设置UITabBarItem中的徽章值
- 3. 如何更改UITabBarItem徽章位置?
- 4. iPhone:从uitabbaritem读取徽章值问题
- 5. 是否可以自定义UITabBarItem徽章?
- 6. 使用NotificationCenter设置徽章值
- 7. 如何在CustomTabbarItem中设置徽章值
- 8. 设置徽章在我的Chrome扩展
- 9. 徽章设计XML
- 10. 快速联系徽章assignContactFromPhone在我的应用程序
- 11. 在推送时设置徽章UITabBarController
- 12. 徽章解锁通知设置
- 13. 如何添加徽章到系统生成的“更多”UITabBarItem
- 14. 确实需要SyncAdapter添加快速联系徽章吗?
- 15. 在AppDelegate的UITabBar项目上设置徽章值
- 16. 使用OneSignal从收到的通知中设置徽章值
- 17. 设置器中的快速返回值
- 18. Mahapps metro徽章控制如何更新徽章的价值
- 19. 是否有可能更改UITabBarItem徽章颜色
- 20. 如何使用自定义UIImage作为UITabBarItem徽章?
- 21. 仅针对当前设备重置CKNotificationInfo徽章值
- 22. 如何使用PushSharp为Windows Phone 8设置徽章值
- 23. iOS 7 UITabBar徽章位置
- 24. 如何将应用程序徽章号码设置为0? (使用解析和快速)
- 25. 如何设置标签中的徽章位置
- 26. Tabhost-设置标签中的徽章位置Android
- 27. Cookie不能快速设置
- 28. 快速设置类属性
- 29. 设置快速DOC时间
- 30. 设置DataGridView快速行高
你想参考红色的徽章与白色'1'? “一个警示标签”并不是特定的;) – milo526
哈哈,我也这么认为,但这是我能想到的最好的方式来描述它。是的,那个1的红色徽章就是我想要的。 – Gino
对不起,最近工作非常忙碌,我会看看,一旦我有时间,并upvote它。干杯 – Gino