//修改cell点击的背景图片
cell.selectedBackgroundView = [[[UIImageView alloc]initWithImage:[[UIImage imageNamed:@"图片"]
stretchableImageWithLeftCapWidth:25 topCapHeight:25]] autorelease];
//修改Cell的背景颜色
@property (nonatomic, retain) UIView *selectedBackgroundView;
//在方法中执行
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * strID = @"ID";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:strID];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strID] autorelease];
}
//修改Cell的分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
[tableView setSeparatorColor:[UIColor redColor]];
cell.contentView.backgroundColor = [UIColor clearColor];//先清除背景颜色
UIView *view = [[UIView alloc] initWithFrame:cell.contentView.frame];
view.backgroundColor = [UIColor redColor];设置选中后cell的背景颜色
self.selectedBackgroundView =view;
return cell;
}
修改Cell的点击效果(背景 颜色)
最新推荐文章于 2023-12-21 20:30:29 发布