Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-colored Shadow Swift

Tags:

ios

swift

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?

like image 609
T. Steele Avatar asked Jan 07 '17 22:01

T. Steele


1 Answers

Thanks to @Josh Homann for pointing me in the right direction, but the answer was actually much more complex.

  1. The first (bottom) UIView in the hierarchy should have a plain white background and be pinned to the edges of the screen.

  2. The next view should be a UIImageView with an alpha of 0.75.

  3. Then you should add a UIVisualEffectView with the same dimensions as the first view.

  4. Finally, add another UIImageView that is the same size as the first UIImageView.

Your IB hierarchy should look similar to this:

IB Hierarchy

The final result is this:

Final Result

like image 148
T. Steele Avatar answered Oct 09 '22 06:10

T. Steele