Iphone 关于iOS开发中的layer.shadow
如果我像这样使用layer.shadow:Iphone 关于iOS开发中的layer.shadow,iphone,objective-c,ios,Iphone,Objective C,Ios,如果我像这样使用layer.shadow: self.layer.shadowOffset = CGSizeMake(0, 1.5); self.layer.shadowColor = [UIColor grayColor].CGColor; self.layer.shadowOpacity = 1; UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds]; self.layer.shadowPath = [path
self.layer.shadowOffset = CGSizeMake(0, 1.5);
self.layer.shadowColor = [UIColor grayColor].CGColor;
self.layer.shadowOpacity = 1;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
self.layer.shadowPath = [path CGPath];
self.layer.shouldRasterize = YES;
并将其中不超过10个没有图像的视图放入UIScroll视图,
它使滚动视图在滚动时非常慢
如果我删除任何关于阴影的代码,滚动就会变得非常平滑
仅供参考,在iOS设备上运行应用程序时会出现不平滑的情况,
但在iOS模拟器上运行平稳
有人知道如何保持阴影和平滑滚动吗 如果设置阴影路径并在图层上设置“应光栅化”标志,则会有所帮助 大概是这样的:
self.layer.shadowOffset = CGSizeMake(0, 1.5);
self.layer.shadowColor = [UIColor grayColor].CGColor;
self.layer.shadowOpacity = 1;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
self.layer.shadowPath = [path CGPath];
self.layer.shouldRasterize = YES;
如果设置阴影路径并在图层上设置“应光栅化”标志,则会有所帮助 大概是这样的:
self.layer.shadowOffset = CGSizeMake(0, 1.5);
self.layer.shadowColor = [UIColor grayColor].CGColor;
self.layer.shadowOpacity = 1;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
self.layer.shadowPath = [path CGPath];
self.layer.shouldRasterize = YES;
我只添加了:self.layer.shouldRasterize=YES。一切都很顺利!谢谢。但是shouldRasterize实际上做什么呢?shouldRasterize将层渲染为位图。以下是文档:我只添加了:self.layer.shouldRasterize=YES。一切都很顺利!谢谢。但是shouldRasterize实际上做什么呢?shouldRasterize将层渲染为位图。以下是文件: