Ana*_*and 10 uitableview ios ios5
我有一个习惯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];
}
}
Run Code Online (Sandbox Code Playgroud)
我能够得到它.但它并不像电子邮件应用程序那样流畅.颜色仅在稍微延迟后才会改变.UITableViewCell应该覆盖哪种方法来放入此代码.我知道以下选项,但它们不会将行为提供给自定义单元格中的自定义标签.
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;
Run Code Online (Sandbox Code Playgroud)
mel*_*sam 23
设置标签的highlightTextColor,这将自动完成.你根本不需要在setSelected做任何特别的事情.
例如
_subjectLabel.highlightedTextColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4778 次 |
| 最近记录: |