我在使用阴影效果方面表现不佳 [英] I Have bad performance on using shadow effect

查看:119
本文介绍了我在使用阴影效果方面表现不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在滚动视图上放了一些图像视图。
当我拖动这个滚动视图时,我没有任何问题。



但是在我将阴影效果应用于这些图像视图后,拖动此滚动视图表现不佳。



我使用了shadowOpacity,shadowRadius和shadowOffset方法。



ex:

  [[anImageView layer] shadowOpacity:1.0]; 

如果使用阴影效果会严重影响性能,我会直接绘制图像阴影。



如果有关于此问题的一些提示,请告诉我们。



我想在iOS上使用阴影效果以编程方式,因为我的绘图技巧最差。



感谢您的阅读。

解决方案

参见 CALayer.shouldRasterize (iOS 3.2+,但是shadowOffset / etc也是如此):


当此属性的值为YES时,图层将在其本地坐标空间中呈现为位图,然后使用任何其他内容合成到目标。滤镜属性中的阴影效果和任何滤镜都被栅格化并包含在位图中。


您可能还需要正确设置rasterizationScale。 / p>

I put some image views on scroll view. And when I drag this scroll view, I didn't have any problems.

But after I applied shadow effect to these image views, dragging this scroll view has bad performance.

I used shadowOpacity, shadowRadius and shadowOffset methods.

ex:

[ [ anImageView layer ] shadowOpacity: 1.0 ];

If using shadow effect causes bad performance seriously, I will draw shadow of the images directly.

If there are some tips about this issues, please let me know them.

I want to use shadow effect on iOS programically, because I have the worst drawing skill.

Thank you for your reading.

解决方案

See CALayer.shouldRasterize (iOS 3.2+, but so is shadowOffset/etc):

When the value of this property is YES, the layer is rendered as a bitmap in its local coordinate space and then composited to the destination with any other content. Shadow effects and any filters in the filters property are rasterized and included in the bitmap.

You probably also want to set rasterizationScale appropriately.

这篇关于我在使用阴影效果方面表现不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆