我想在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]
}
我想在通知按钮上添加计数徽章。我进行了搜索,但没有得到适当的解决方案。谁能解释我如何做到这一点
答案 0 :(得分:0)
https://github.com/TanguyAladenise/BBBadgeBarButtonItem尝试使用此Pod,它可能满足您的要求,但是它是用目标C编写的,但是相当容易使用!!!