ios - 更改 MoreNavigationController TableView Row 中的角标(Badge)值文本和背景颜色?

标签 ios swift uitableview uinavigationcontroller uitabbarcontroller

我已经完全自定义了 MoreNavigationController,但我无法弄清楚最后一点...如何更改表格 View 行的角标(Badge)文本和背景颜色?请参见下图...

BadgeColor

最佳答案

弄清楚了...添加到您的 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)
                        }
                    }
                }
            }
        }
    }

关于ios - 更改 MoreNavigationController TableView Row 中的角标(Badge)值文本和背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53049108/

相关文章:

ios - 如何解决地址簿中对象泄露的问题

iphone - 对 <TSActivityMapVC : 0x81b1000> 的开始/结束外观转换的调用不平衡

iphone - UITableView 帧变化动画问题

ios - 没有@synthesizing 的@property 声明

ios - 直接从我自己的 iOS 应用程序打开 Microsoft Office 文档进行就地编辑

ios - 显示多个图像会导致大量内存使用

ios - Sprite Kit - 更改 SKShapeNode 的 anchor 不会更改 SKPhysicalBody 位置

php - 如何将验证错误从 php 或 segue 成功返回到 swift

ios - 如何同时更新每个自定义tableview单元格数据?

iphone - iPhone 核心数据新功能