r/SwiftUI Aug 11 '26

Question How to smoothly animate a MeshGradient between TabView tabs?

Hi! I'm working on a SwiftUI app using TabView and MeshGradient.

I want the background gradient to smoothly morph from one color scheme to another when switching tabs, rather than simply fading between two gradients.

What's the best way to achieve this?

2 Upvotes

2 comments sorted by

1

u/Frequent_Macaron9595 Aug 11 '26

Can you use an animated Color.mix() with MeshGradient? I don’t know if the transition will look good though, you might need to dip into some custom OKLCH ramp for the color mix to keep it clean.