iOS-阴影无法正确调整大小
我有一个具有动态单元格大小的tableView,在重复使用单元格时无法调整阴影的大小。此解决方案适用于iOS8,但不适用于iOS7。此外,阴影在第一次创建阴影时会根据单元大小正确显示,但在重复使用单元后会断开iOS-阴影无法正确调整大小,ios,calayer,shadow,Ios,Calayer,Shadow,我有一个具有动态单元格大小的tableView,在重复使用单元格时无法调整阴影的大小。此解决方案适用于iOS8,但不适用于iOS7。此外,阴影在第一次创建阴影时会根据单元大小正确显示,但在重复使用单元后会断开 @implementation static const CGFloat shadowWithInset = 2; static const CGFloat shadowHeightOutset = 4; - (void)awakeFromNib { CALay
@implementation
static const CGFloat shadowWithInset = 2;
static const CGFloat shadowHeightOutset = 4;
- (void)awakeFromNib {
CALayer *layer = self.innerView.layer;
layer.shadowOffset = CGSizeMake(1, 1);
layer.shadowRadius = 3.0f;
layer.shadowColor = [[UIColor gray] CGColor];
layer.shadowOpacity = 0.8f;
//layer.shouldRasterize = YES;
//layer.rasterizationScale = [UIScreen mainScreen].scale;
CGSize size = layer.bounds.size;
layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(shadowWithInset, size.height-shadowHeightOutset, size.width-(shadowWithInset*2), shadowHeightOutset)].CGPath;
}
- (void)layoutSubViews {
[super layoutSubviews];
CGSize size = self.innerView.bounds.size;
layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(shadowWithInset, size.height-shadowHeightOutset, size.width-(shadowWithInset*2), shadowHeightOutset)].CGPath;
}
@end
在CellForRowatineXpath中填充所有文本字段后,我最终执行了以下操作:
[self setNeedsLayout];
[self layoutIfNeeded];