【发布时间】:2012-05-26 15:25:07
【问题描述】:
我有一个自定义UITableViewCell。它内部有 3 个自定义标签和自定义文本。
当我点击单元格时,我希望所有这些标签的 textColor 变为白色。就像电子邮件应用 UITableViewCell 行为一样。
为此,我在自定义单元格类中编写了这个。
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
if (self.selected) {
_subjectLabel.textColor = [UIColor whiteColor];
_messageLabel.textColor = [UIColor whiteColor];
_usernameLabel.textColor = [UIColor whiteColor];
}else {
_subjectLabel.textColor = [UIColor blackColor];
_messageLabel.textColor = [UIColor grayColor];
_usernameLabel.textColor = [UIColor blackColor];
}
}
我能够得到它。但它不像在电子邮件应用程序中那样流畅。颜色仅在一小段延迟后发生变化。我应该重写 UITableViewCell 的哪个方法来放入此代码。我知道以下选项,但它们不会将行为赋予自定义单元格中的自定义标签。
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;
【问题讨论】:
标签: ios ios5 uitableview