iOS边练边学--UITableViewCell的常见属性设置

 1 // 取消选中的样式(常用) 让当前 cell 按下无反应
 2 cell.selectionStyle = UITableViewCellSelectionStyleNone;
 3 
 4 // 设置选中的背景色,UIView无需设置UIView的尺寸
 5 UIView *selectedBackgroundView = [[UIView alloc] init];
 6 selectedBackgroundView.backgroundColor = [UIColor redColor];
 7 cell.selectedBackgroundView = selectedBackgroundView;
 8 
 9 // 设置默认的背景色,优先级低
10 cell.backgroundColor = [UIColor blueColor];
11 
12 // 设置默认的背景色,优先级高
13 UIView *backgroundView = [[UIView alloc] init];
14 backgroundView.backgroundColor = [UIColor greenColor];
15 cell.backgroundView = backgroundView;
16 
17 // backgroundView的优先级 > backgroundColor
18 // 设置指示器,系统默认的几个选项
19 // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
20 // 也可以自己设置指示器,这里讲指示器做成了开关
21 cell.accessoryView = [[UISwitch alloc] init];
原文地址:https://www.cnblogs.com/gchlcc/p/5279763.html