如果我像这样使用 layer.shadow :
self.layer.shadowOffset = CGSizeMake(0, 1.5);
self.layer.shadowColor = [UIColor grayColor].CGColor;
self.layer.shadowOpacity = 1;
并将其中一些(不超过 10 个) View (没有图像)放入
UIScrollView
,它使
scrollView
滚动时非常慢。如果我删除任何关于阴影的代码,滚动就会再次变得非常流畅。
仅供引用,在 iOS 设备上运行应用程序时会发生不顺利的情况,
但在 iOS 模拟器上流畅。
有谁知道如何同时保持阴影和平滑滚动?
最佳答案
如果您设置阴影路径并在图层上设置应该光栅化标志,这将有所帮助。
像这样的东西:
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
self.layer.shadowPath = [path CGPath];
self.layer.shouldRasterize = YES;
关于iphone - iOS开发中关于layer.shadow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8930273/