iOS Tableable cell 自定义点击背景效果

 //先设置背景色

    _backImgView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * KSCALE_X, 0, IPHONE_WIDTH - 40 * KSCALE_X, self.frame.size.height)];

    _backImgView.backgroundColor = kColor(231, 231, 231);

    

    _backImgView = [[UIImageView alloc]initWithImage:[CommonTools createImageWithColor:kColor(231, 231, 231)] highlightedImage:[CommonTools createImageWithColor:kColor(196, 202, 216)]];

    

    [self.contentView addSubview:_backImgView];

//设置高度

    _backImgView.frame = CGRectMake(20 * KSCALE_X, 0, IPHONE_WIDTH - 40 * KSCALE_X, _speciaView.frame.size.height + _speciaView.frame.origin.y + 10);


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{


   UIView *view_bg = [[UIView alloc]initWithFrame:cell.frame];

        view_bg.backgroundColor = [UIColor clearColor];

        cell.selectedBackgroundView = view_bg;


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


    DSLog(@"点击社区详情  cell");

    

    //当离开某行时,让某行的选中状态消失

    [tableView deselectRowAtIndexPath:indexPath animated:NO];


    

    

}




猜你喜欢

转载自blog.csdn.net/qq_27247497/article/details/52128423