画一个隐藏在半透明视图下的阴影? [英] Draw a shadow which is hidden under the semi-transparent view?

查看:192
本文介绍了画一个隐藏在半透明视图下的阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带阴影的半透明视图。我在photoshop中嘲笑它,它不会在对象下绘制阴影。然后我在xcode中创建了它,但它显然确实在下面绘制了阴影。我想知道是否有办法避免这种情况。换句话说 - 阴影只出现在形状之外?

I have a semi-transparent view with a drop shadow. I mocked it up in photoshop, which doesn't draw the shadow under the object. Then I made it in xcode, but it obviously does draw the shadow underneath. I was wondering if there's a way to avoid this. In other words - have the shadow only appear outside of the shape?

推荐答案

您可能想要设置图层的栅格化属性到YES,它会在其他效果(如不透明度)应用于视图之前合成阴影。

You probably want to set the rasterized property of the layer to YES, which will composite the shadow before other effects such as opacity are applied to the view.

但请注意,这会对性能产生很大影响。这里有一个方便的表格,其中包含不同的影子实现及其性能影响: http://www.omnigroup。 com / blog / entry / ipad_drop_shadow_performance_test /

Note however that this has a big performance impact. There's a handy table of different shadow implementations and their performance implications here: http://www.omnigroup.com/blog/entry/ipad_drop_shadow_performance_test/

这篇关于画一个隐藏在半透明视图下的阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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