1.UITableView的常用属性
//设置tableView每一行cell的高度
tableview.rowHeight = 100;
//设置tableView每一组的头部高度
tableView.sectionHeaderHeight = 80;
//设置tableView每一组的尾部高度
tableView.sectionFooterHeight = 80;
//设置分割线的颜色
tableView.separatorColor = {UIColor redColor};
//设置分割线的样式
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//设置表头控件
tableView.tableHeaderView = [[UISwitch alloc] init];
//设置表尾控件
tableView.tableFooterView = [[UISwitch alloc] init];
2.UITableViewCell的常见属性
cell.textLabel.text = @“要显示的文字”; //文字
cell.imageView.image = [UIImage imageNamed:@“图片的名字”]; //图片
cell.accessoryType = UITableViewCellAccessoryCheckmark; //设置cell右边的指示样式
cell.accessoryView = [[UISwitch alloc] init]; //设置cell右边显示的控件,优先级高于accessoryType
cell.selectionStyle = UITableViewCellSelectionStyleNone; //设置当选中cell时的样式
cell.backgroundColor = [UIColor redColor]; //设置cell的背景颜色
UIView *backgroundView = [[UIView alloc] init];
backgroundView.backgroundColor = [UIColor blueColor];
cell.backgroundView = backgroundView; //设置cell的背景view,优先级高于backgroundColor,但与backgroundColor同时设置时可能显示上有冲突
cell.selectedBackgroundView = backgroundView; //设置当cell被选中时的背景view