[containerFrame.layer setShadowOffset:CGSizeMake(0,1)];[containerFrame.layer setShadowRadius:4.0];[containerFrame.layer setShadowcolor:[UIcolor colorWithRed:34/255.f green:25/255.f blue:25/255.f Alpha:1.0].CGcolor];[containerFrame.layer setShadowOpacity:0.4];
有了这个,我的滚动FPS下降到20-30.移除阴影然后繁荣,我的FPS回到60并且滚动像黄油一样光滑.现在的问题是我需要在这个盒子/容器视图周围有一个阴影效果.如何在不降低滚动速度的情况下实现这一目标?
解决方法 尝试设置阴影路径:[containerFrame.layer setShadowOffset:CGSizeMake(0,1)];[containerFrame.layer setShadowRadius:4.0];[containerFrame.layer setShadowcolor:[UIcolor colorWithRed:34/255.f green:25/255.f blue:25/255.f Alpha:1.0].CGcolor];[containerFrame.layer setShadowOpacity:0.4];// New line[containerFrame.layer setShadowPath:[UIBezIErPath bezIErPathWithRect:containerFrame.bounds].CGPath];
If you have to animate this vIEw (and especially if it’s part of a
UItableVIEwCell) you will probably notice stutters in the animation.
This is because calculating the drop shadow for your vIEw requires
Core Animation to do an offscreen rendering pass to determine the
exact shape of your vIEw in order to figure out how to render its drop
shadow. (Remember,your vIEw Could be any complex shape,possibly
even with holes in it.)
从On the importance of setting shadowPath起.
总结以上是内存溢出为你收集整理的iphone – 向单元格添加阴影会导致延迟滚动全部内容,希望文章能够帮你解决iphone – 向单元格添加阴影会导致延迟滚动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)