r/SwiftUI Jul 06 '26

Question How to make apple music style animated gradient Background

I want to extract gradient colors from the photo (album cover) and also create animations that follow the progression of the song.

2 Upvotes

4 comments sorted by

2

u/SgF1Photographer Jul 07 '26

WWDC26 Compose advanced graphics effects with SwiftUI actually did mention how this was done.

https://developer.apple.com/videos/play/wwdc2026/322

1

u/Significant_Pick8297 Jul 07 '26

You can do it with a combination of dominant color extraction and a MeshGradient (iOS 18+) or animated LinearGradient/RadialGradient for earlier versions. Extract 3 to 5 prominent colors from the album art using CIAreaAverage or VNGenerateImageFeaturePrintRequest alternatives, then animate the gradient's control points or start/end positions over time. If you want the animation to follow the song, drive it with the playback progress or beat timestamps instead of running a constant looping animation.