1、cell右边添加箭头
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"technician_lookatall_arrow"]];
2、cell下面的横线定格
//解决iOS7、8中tableView分割线缺少15像素
if ([_contentTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[_contentTableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([_contentTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[_contentTableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
//解决iOS7、8中tableView分割线缺少15像素(需要和上面一起使用才能达到效果)
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
3、改变cell的背景颜色
cell.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.2];
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];
4、UITableView代理快捷引用
#pragma mark - UITableViewDelegate、UITableViewDataSource代理
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIndentifier = @"cellInfo";
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
if (!cell) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentifier];
cell.backgroundColor = [UIColor whiteColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
Model *model = dataArray[indexPath.row];
[cell setContentWithModel:model andShowView:isShow]; //默认不显示控件
return cell;
}