由于项目列表比较复杂,将部分列表的内容用tableView展示并作为一个cell放在父容器的tableView中,通过提前计算子tableView的总高度然后刷新大的tableView的列表,功能是完成了,但是tableView plain模式下,headerView和footerView默认有个灰色的背景,发现设置如下并不能生效
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
最后发现一个简洁的办法设置背景颜色
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
view.tintColor = UIColor.clearColor;
}
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section{
view.tintColor = UIColor.clearColor;
}
设置虚线的办法
-(void)layoutSubviews{
[super layoutSubviews];
[self.layer addSublayer:self.dottedLine];
}
- (CAShapeLayer *)dottedLine {
if (_dottedLine) {
return _dottedLine;
}
_dottedLine = [CAShapeLayer layer];
_dottedLine.strokeColor = FONT_COLOR_EEEEEE.CGColor;
_dottedLine.fillColor = nil;
UIBezierPath* path = [UIBezierPath bezierPath];
path.lineWidth = 1.f;
path.lineCapStyle = kCGLineCapRound;
path.lineJoinStyle = kCGLineJoinRound;
[path moveToPoint:CGPointMake(kRealValue(89), 8)];
[path addLineToPoint:CGPointMake(kRealValue(89), kRealValue(58) - 8)];
_dottedLine.path = path.CGPath;
_dottedLine.frame = CGRectMake(0, 0, 1, kRealValue(58) - 8 );
_dottedLine.lineWidth = 1.f;
_dottedLine.lineCap = @"square";
_dottedLine.lineDashPattern = @[@4, @3];
return _dottedLine;
}