iphone - 在突出显示时更改 UITableView cell.detailTextLabel 颜色

标签 iphone objective-c ios uitableview

选中时 UITableView 中文本的默认颜色为白色。我想将其更改为深灰色。通过这样做,我设法更改了主标题标签文本:

cell.selectedTextColor = [UIColor darkGrayColor];

当 detailTextLabel 被突出显示/选中时,我如何为它执行此操作?

谢谢

最佳答案

您可以继承 UITableViewCell。然后重写 setHighlighted:animated 方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
       [super setHighlighted:highlighted animated:animated];
       if (highlighted) {
           self.detailTextLabel.textColor = [UIColor lightGrayColor];
       } else {
           self.detailTextLabel.textColor = [UIColor whiteColor];
       }
}

您最终可能还想覆盖 setSelected:animated 方法。

关于iphone - 在突出显示时更改 UITableView cell.detailTextLabel 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9558570/

相关文章:

objective-c - 如何使用 ARC 在 NSArray 中存储 CFUUIDRef 对象?

iphone - 数据服务器到 iPhone 并返回

ios - 在 Xcode 5.1 中构建时出现 "You must provide a screenshot for 5.5-inch Retina display, because your app binary supports 5.5-inch Retina displays"

ios - 获取预处理器宏的特定值

android - iOS 和安卓的代码生成

iphone - 淡入淡出动画 UITableViewCell

ios - 如何从 Apple App Store 中暂时删除我的应用程序?

iphone - 使用mailto时出错: link in Mobile Safari in app-capable mode

ios - 如何在 iOS 终止后打开应用程序时重新打开最后一个 View

ios - segue 和 NavigationController 导航有什么问题