作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
如何使用 swift 设置标签栏角标(Badge)?例如,当我收到消息图标上显示数字 1 的新消息时!我是否必须使用 UITabBarItem.swift 并在其中编写代码!我不太确定我该怎么做
谢谢!
最佳答案
如果您获得了对 tabBarController 的引用(例如来自 UIViewController),您可以执行以下操作:
if let tabItems = tabBarController?.tabBar.items {
// In this case we want to modify the badge number of the third tab:
let tabItem = tabItems[2]
tabItem.badgeValue = "1"
}
在 UITabBarController 中,它将是 tabBar.items
而不是 tabBarController?.tabBar.items
并删除角标(Badge):
tabItem.badgeValue = nil
关于ios - 如何用swift设置标签栏角标(Badge)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43111413/
我是一名优秀的程序员,十分优秀!