【发布时间】:2018-07-30 07:30:33
【问题描述】:
我想在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]
}
我想在通知按钮上添加计数徽章。我搜索了它,但我没有得到适当的解决方案。谁能解释我如何做到这一点并实现它
【问题讨论】:
-
我鼓励您查看 UIBarButtonItem(customView: UIView)。编写您的自定义视图(由徽章覆盖的 3dot)并将其作为参数传递。
-
很抱歉我没听懂
标签: ios swift notifications badge