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

2017-11-06  本文已影响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]

上一篇 下一篇

猜你喜欢

热点阅读