【问题标题】:Add Badge count icon on BarButtonItem Swift [duplicate]在 BarButtonItem Swift 上添加徽章计数图标 [重复]
【发布时间】: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


【解决方案1】:

https://github.com/TanguyAladenise/BBBadgeBarButtonItem 试试这个 pod,它可能会满足您的要求,但它是用 Objective C 编写的,但相当容易使用!!!

【讨论】:

猜你喜欢
  • 2016-03-21
  • 1970-01-01
  • 2017-12-12
  • 1970-01-01
  • 2018-02-25
  • 1970-01-01
  • 2014-11-09
  • 1970-01-01
  • 2020-01-18
相关资源
最近更新 更多