我想实现这种效果, 点击时 改变cell的背景色, 和里面label的颜色, 点击另一个时, 之前的一个恢复之前的颜色, 我试了试 用didSelectRowAtIndexPath 方法, 里面去得到cell, 改变颜色,但是当点击其他的cell的时候, 之前的cell如何恢复原样? 还是我的思路不对,请指教
迷茫2017-04-17 17:46:49
Customize UITableViewCell and overload its methods
\- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
// 这个判断selected,设置子试图状态
if (selected) {
//......
}
else {
//......
}
}
PHP中文网2017-04-17 17:46:49
Seeing that you are a beginner, let me give you some directions first
// UILabel.h
@property(nonatomic, strong) UIColor *highlightedTextColor
// UITableViewCell.h
// 背景View
@property (nonatomic, strong, nullable) UIView *selectedBackgroundView;
// 选中事件
- (void)setSelected:(BOOL)selected {}
If you still have any questions, you can reply