iOS 自定义cell点击背景颜色 并在点击后消失

当前cell的自定义背景颜色

    BMMineTableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier: BMMineTVCellIdentifier];
    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
    cell.selectedBackgroundView.backgroundColor = BMColor(@"#f0f5f7");
    
    return cell;

Cell点击后选中的颜色消失

//cell点击,在代理方法中写
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //点击后cell的选中颜色消失
    [self performSelector:@selector(delectCellColor:) withObject:nil afterDelay:0.5];
}


//cell的选中颜色消失
- (void)delectCellColor:(id)sender{
    [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容