iOS Tableable cell custom click background effect

 // Set the background color first

    _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];

//Set height

    _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 ( @" click the community details   cell" );

    

    // When leaving a row, let the selected state of a row disappear

    [tableView deselectRowAtIndexPath:indexPath animated:NO];


    

    

}




Guess you like

Origin blog.csdn.net/qq_27247497/article/details/52128423