一个信息输入tableView
1.控制sectionHeader和tableView背景色一致
2.实现如下方法,否则heightForFooter默认不是0,当人header同样
3.给输入列表加边框
-(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
{
if([cellrespondsToSelector:@selector(tintColor)]) {
cell.backgroundColor= [UIColorwhiteColor];
CAShapeLayer*layer = [[CAShapeLayeralloc]init];
CGMutablePathRefpathRef =CGPathCreateMutable();
CGRectbounds =CGRectInset(cell.bounds,0,0);
CGFloatcornerRadius =2.0f;
if(indexPath.row==0) {
CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMaxY(bounds));
CGPathAddArcToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMinY(bounds),CGRectGetMidX(bounds),CGRectGetMinY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMinY(bounds),CGRectGetMaxX(bounds),CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
}elseif(indexPath.row==self.dataSourceArray.count-1) {
CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMinY(bounds));
CGPathAddArcToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMaxY(bounds),CGRectGetMidX(bounds),CGRectGetMaxY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMaxY(bounds),CGRectGetMaxX(bounds),CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
}else{
CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMinY(bounds));
CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
CGPathMoveToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMinY(bounds));
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
}
//颜色修改
layer.strokeColor= [UIColorcolorWithRGBString:cellEdgeLineColor].CGColor;
layer.fillColor= [UIColorwhiteColor].CGColor;
layer.path= pathRef;
CFRelease(pathRef);
BOOLaddLine =NO;
if(indexPath.row!=self.dataSourceArray.count-1) {
addLine =YES;
}else{
addLine =NO;
}
if(addLine ==YES) {
CALayer*lineLayer = [[CALayeralloc]init];
CGFloatlineHeight = (2.0f/ [UIScreenmainScreen].scale);
lineLayer.frame=CGRectMake(CGRectGetMinX(bounds), bounds.size.height-lineHeight, bounds.size.width
, lineHeight);
lineLayer.backgroundColor= [UIColorcolorWithRGBString:cellSeparatorLineColor].CGColor;
[layeraddSublayer:lineLayer];
}
UIView*testView = [[UIViewalloc]initWithFrame:bounds];
[testView.layerinsertSublayer:layeratIndex:0];
testView.backgroundColor=UIColor.clearColor;
cell.backgroundView= testView;
}
}
4.准确确定tableFooterView高度
5.整体效果