美文网首页
iOS 自定义cell点击背景颜色 并在点击后消失

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

作者: 李栖桐 | 来源:发表于2017-11-06 16:39 被阅读20次

当前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]

相关文章

网友评论

      本文标题:iOS 自定义cell点击背景颜色 并在点击后消失

      本文链接:https://www.haomeiwen.com/subject/egblmxtx.html