问题描述
在iOS音乐应用中,我注意到专辑封面下的阴影会根据艺术作品的颜色而变化。根据图稿边缘的颜色如何变化,此阴影也可以是多色的。
In the iOS music app, I've noticed the shadow underneath album artwork changes based on the color of the artwork. This shadow can also be multi-colored based on how the color at the edge of the artwork changes.
有没有人知道如何以编程方式重新创建此效果?
Does anyone know how to recreate this effect programmatically?
推荐答案
感谢@Josh Homann指出我正确的方向,但答案实际上要复杂得多。
Thanks to @Josh Homann for pointing me in the right direction, but the answer was actually much more complex.
-
层次结构中的第一个(底部)UIView应该具有纯白色背景并固定在屏幕边缘。
The first (bottom) UIView in the hierarchy should have a plain white background and be pinned to the edges of the screen.
下一个视图应该是一个字母为0.75的UIImageView。
The next view should be a UIImageView with an alpha of 0.75.
然后你应该添加一个UIVisualEffectView维度作为第一个视图。
Then you should add a UIVisualEffectView with the same dimensions as the first view.
最后,添加另一个与第一个UIImageView 相同大小的UIImageView。
Finally, add another UIImageView that is the same size as the first UIImageView.
您的IB层次结构应该类似于:
Your IB hierarchy should look similar to this:
最终结果如下:
这篇关于多色阴影斯威夫特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!