减少ios中的Tableview可选区域

时间:2015-10-20 06:14:28

标签: ios objective-c uitableview

1您好,在我的项目中,需要显示表行选择(蓝色),只有行的一半。有任何方法可以执行此操作。

所选单元格应为蓝色,其余均为白色。请帮我解决这个问题。我不想重新加载表,因为很多图像都是从服务器加载的。如果再次重新加载会降低性能。

[请在选择后查看图片,单元格应如下所示]

enter image description here

3 个答案:

答案 0 :(得分:0)

您可以将selectedBackgroundView的{​​{1}}属性设置为半蓝色的视图。

答案 1 :(得分:0)

在didSelectRowAtIndexpath中获取单元格..

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
 UITableViewCell *myCell = [tableView cellForRowAtIndexPath:indexPath];

 // add view as per your according to need  in cell 

 UIView * myCellAccessoryView = [UIview alloc] init];

 // set frame of myCellAccessoryView as per your need ..
 myCellAccessoryView.backGroundColor = // set color as you need .

// and add in cell 
 [cell.contentView addSubView :myCellAccessoryView];

}
希望它可以帮助你..

答案 2 :(得分:0)

您可以使用此

UIView *backView = [[UIView alloc]init];
backView.frame = CGRectMake(0, 0, cell.frame.size.width/2, cell.frame.size.height);
backView.backgroundColor    =[UIColor blueColor];
[cell addSubview:backView];

这将创建一个蓝色背景视图。

相关问题