【问题标题】:Changing badge value text and background color in MoreNavigationController TableView Row?在 MoreNavigationController TableView Row 中更改徽章值文本和背景颜色?
【发布时间】:2019-04-02 14:20:59
【问题描述】:

我已经完全自定义了 MoreNavigationController,但我无法弄清楚最后一点...如何更改 tableview 行的徽章文本和背景颜色?见下图……

【问题讨论】:

    标签: ios swift uitableview uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    想通了...添加到您的 tabBarController 类:

    UINavigationControllerDelegate
    

    然后设置:

    moreNavigationController.delegate = self
    

    然后添加这个:

    func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
            if (self.moreNavigationController.topViewController?.title == "More"){
                let moreTableView = self.moreNavigationController.topViewController!.view as! UITableView
    
                for cell in moreTableView.visibleCells {
    
                    for views in cell.subviews {
    
                       // print(views.description.contains("_UITableViewCellBadgeNeue"))
    
                        for items in views.subviews {
                            if (items is UILabel) {
                                let item = items as! UILabel
                                item.textColor = UIColor.white
                                item.backgroundColor = UIColor(red: 27, green: 27, blue: 27, transparancy: 100)
                            }
                        }
                    }
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2020-02-18
      • 1970-01-01
      • 1970-01-01
      • 2011-06-23
      • 2018-12-25
      • 1970-01-01
      • 1970-01-01
      • 2015-06-03
      • 1970-01-01
      相关资源
      最近更新 更多