T. Steele
T. Steele

Reputation: 325

Multi-colored Shadow 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?

Upvotes: 6

Views: 1887

Answers (3)

Alejandro Cotilla
Alejandro Cotilla

Reputation: 2621

Sorry to revive an old question, but this library nailed it: ShadowImageView.

It uses CIFilter which gives you more control over the blur effect and better results.

Upvotes: 0

T. Steele
T. Steele

Reputation: 325

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

Upvotes: 6

Josh Homann
Josh Homann

Reputation: 16327

Its not a shadow its a UIVisualEffectView with a blur. Add a second image view under your image view with a larger size and add a blurring visualEffectView to it.

Upvotes: 1

Related Questions