nig*_*xed 4 objective-c uitableview tableviewcell ios
我有一个习惯UITableViewCell,有一个UILabel和一个UIImageView.我想在突出显示单元格时更改背景颜色和文本颜色.在我CustomCell的setHighlighted方法中,我有以下代码:
-(void)setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
if(self) {
if(highlighted) {
self.title.textColor = [UIColor whiteColor];
} else {
self.title.textColor = [UIColor blackColor];
}
//highlight background
UIView *bgColorView = [[UIView alloc] initWithFrame:self.frame];
bgColorView.backgroundColor = [UIColor blackColor];
[self setSelectedBackgroundView:bgColorView];
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试将代码textColor更改为tableView's didSelectRowAtIndexPath,但这不是我想要的效果 - 我希望文本颜色在用户触摸单元格时更改 - 而不是在触摸时.有什么建议?
Sim*_*egn 11
您应该使用该属性highlightedTextColor.设置内部单元格的颜色tableView:cellForRowAtIndexPath,它应如下所示:
cell.textLabel.highlightedTextColor = [UIColor blueColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2726 次 |
| 最近记录: |