Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在BarButtonItem Swift上添加徽章计数图标_Ios_Swift_Notifications_Badge - Fatal编程技术网

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。我试着去做,这很容易