我有一个自定义的 tableview 单元子类,它绘制了一个阴影......
当我向下滚动时,一些单元格没有绘制阴影......
当我向上滚动时也会发生这种情况。
我尝试将绘图代码移动到单元格子类 drawRect、setNeedsLayout。我也在 tableviewController 的配置单元格方法中尝试过这个。
self.layer.shadowRadius = 4.1f;
self.layer.shadowOpacity = 0.5;
self.layer.shadowOffset = CGSizeMake(2.1f,7.4f);
CGFloat curlFactor = 15.00f;
CGFloat shadowDepth = 4.6f;
CGSize size = self.layer.bounds.size;
UIBezierPath* path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0.0f, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, size.height + shadowDepth)];
[path addCurveToPoint:CGPointMake(0.0f, size.height + shadowDepth)
controlPoint1:CGPointMake(size.width - curlFactor, size.height + shadowDepth - curlFactor)
controlPoint2:CGPointMake(curlFactor, size.height + shadowDepth - curlFactor)];
[self.layer setShadowPath:[path CGPath]];
提前致谢。