在 MoreNavigationController TableView 行中更改徽章值文本和背景颜色?
Changing badge value text and background color in MoreNavigationController TableView Row?
我已经完全自定义了 MoreNavigationController,但我无法弄清楚最后一点...如何更改 tableview 行的徽章文本和背景颜色?见下图...
想通了...添加到您的 tabBarController class:
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)
}
}
}
}
}
}
我已经完全自定义了 MoreNavigationController,但我无法弄清楚最后一点...如何更改 tableview 行的徽章文本和背景颜色?见下图...
想通了...添加到您的 tabBarController class:
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)
}
}
}
}
}
}