Ios 在BarButtonItem Swift上添加徽章计数图标
我想在我在Ios 在BarButtonItem Swift上添加徽章计数图标,ios,swift,notifications,badge,Ios,Swift,Notifications,Badge,我想在我在UINavigationBar中使用的图标上添加一个徽章图标 这是迄今为止我所做的 let threeDotButton = UIBarButtonItem(image:UIImage(named: "ic_more.png")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(DashboardViewController.threeDotImageClick))
UINavigationBar
中使用的图标上添加一个徽章图标
这是迄今为止我所做的
let threeDotButton = UIBarButtonItem(image:UIImage(named: "ic_more.png")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(DashboardViewController.threeDotImageClick))
let notificationButton = UIBarButtonItem(image:UIImage(named: "ic_notifications.png")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(DashboardViewController.notificationImageClick))
self.tabBarController?.navigationItem.rightBarButtonItems = [threeDotButton,notificationButton]
let title = UILabel()
title.text = "Dashboard"
self.tabBarController?.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: title)
if let fontstyle = UIFont(name: "Roboto", size: 30) {
self.tabBarController?.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: fontstyle]
}
我想在通知按钮上添加计数徽章。我搜索了一下,但没有找到合适的解决办法。有人能告诉我怎么做和实现它吗?试试这个吊舱。它可能满足你的要求,但它是用C语言写的,但相当容易使用 我鼓励您研究uibarbuttonite(customView:UIView)。撰写您的自定义视图(3dot由一个徽章覆盖)并将其作为参数传递。很抱歉,我没有理解好,我不熟悉objective C。我试着去做,这很容易