您的位置:首页 > 产品设计 > UI/UE

自定义UITableViewCell 的选中背景图片

2012-10-09 10:58 369 查看
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];

if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:kCellIdentifier]
autorelease];

cell.selectionStyle = UITableViewCellSelectionStyleBlue; //只有设置这个选择类型,后面的selectedBackgroundView才有作用,不然设置none的话就不起作用

/* Background */
cell.backgroundView = [[[UIImageView alloc] init] autorelease];
cell.selectedBackgroundView = [[[UIImageView alloc] init] autorelease];
}

cell.backgroundView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"customBackground"]];
cell.selectedBackgroundView.backgroundColor = [UIColor redColor];

return cell;
}


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: