我在表格视图的单元格中使用背景图像,并使用阴影不透明度,但它在滚动时非常低。如何调音?



我在tableview的单元格中使用背景图像并使用shadowOpacity,但它在滚动时很低。如何调音?

self.backgroundImageView.backgroundColor = [UIColor colorWithRed:241 green:241 blue:241 alpha:1];
self.backgroundImageView.layer.cornerRadius = 10;
self.backgroundImageView.layer.shadowOffset = CGSizeMake(0, 0);
self.backgroundImageView.layer.shadowOpacity = 0.3;
self.backgroundImageView.layer.masksToBounds = NO;

您应该将图层的shadowPath属性设置为与圆角矩形匹配的路径。比如:

self.backgroundImageView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.backgroundImageView.bounds cornerRadius:10.0].CGPath;

如果没有这些信息,图层必须分析它的内容来决定在哪里渲染阴影,这是损害你的滚动性能的原因。

最新更新