ios - tableview cell 选中后 改变颜色
PHPz
PHPz 2017-04-17 17:44:49
0
2
906


我想实现这种效果, 点击时 改变cell的背景色, 和里面label的颜色, 点击另一个时, 之前的一个恢复之前的颜色, 我试了试 用didSelectRowAtIndexPath 方法, 里面去得到cell, 改变颜色,但是当点击其他的cell的时候, 之前的cell如何恢复原样? 还是我的思路不对,请指教

PHPz
PHPz

学习是最好的投资!

reply all(2)
迷茫

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 {
        //......
    }
}
洪涛

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!