Changing background color of selected cell?

后端 未结 30 2970
太阳男子
太阳男子 2020-11-29 00:22

Does anyone know how to change the background color of a cell using UITableViewCell, for each selected cell? I created this UITableViewCell inside the code for TableView.

30条回答
  •  情书的邮戳
    2020-11-29 00:51

    This worked perfectly with grouped calls: Implement a custom subclass of UITableViewCell

    This will respect corners and such...

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
    
        if(selected)
            [self setBackgroundColor:[UIColor colorWithRed:(245/255.0) green:(255/255.0) blue:(255/255.0) alpha:1]];
        else
            [self setBackgroundColor:[UIColor whiteColor]];
    
    }
    

提交回复
热议问题