如何使用快速代码设置Tabbar项目标志?

问题描述

如何创建一个计数按钮单击次数显示在索引3的选项卡上的循环?这是我的代码

@IBAction func btnBuy(_ sender: UIButton) { 
let tabItems = self.tabBarController?.tabBar.items as NSArray?
let btnBarBadge = tabItems![3] as! UITabBarItem
btnBarBadge.badgeValue = "\(countItem)" }

enter image description here

我编写了此函数来存储用户单击按钮的次数,但是当我检查它时,发现countItem上没有存储任何值

func clickCount() {
        if roundedCornerButton.isSelected == true{
       countItem = countItem + 1
       arrayNumOfItem.append(countItem)
       print("\(countItem)")
        }
   }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)