how to draw mesh gradient in swiftui

Viewed 34

can you please explain how to draw/make a mesh gradient in swiftUI similar to the attached image? I it straightforward to use LinearGradient, RadialGradient, or Angular gradient but none of them produce something similar to the attached image as far as I know. Can you please help me with my request?

enter image description here

I tried different values for the the angle degree, but still not the result I'm looking for. Below is the code I have so far:

struct ContentView: View {
let gradient = Gradient(colors: [Color(.systemRed),
                                 Color(.systemBlue),
                                 Color(.systemGray),
                                 Color(.systemPurple),
                                 Color(.systemYellow),
                                 Color(.systemRed)])

var body: some View {
    
    VStack {
        Text("")
    }
    .frame(width: 300, height: 300)
    .background(
        AngularGradient(gradient: gradient,
                        center: .center,
                        angle: .degrees(180)) // (180 + 45)
    )
 }
0 Answers
Related