Multiple Gradients with Shapes
SwiftUI gives us so many ways to add the gradient. A color gradient represented as an array of color stops, each having a parametric location value.

Getting Started
- Text with Linear Gradient.
- Text with Gradient and CornerRadius.
- Text with Gradient, CornerRadius & Shadow.
- Text with Radial Gradient, CornerRadius & Shadow.
- Text with Angular Gradient, CornerRadius & Shadow.
- Text with Angular Gradient, CornerRadius, Shadow & Circle Shape.
- Text with Angular Gradient, CornerRadius, Shadow & Rectangle Shape.
- Gradient that masked with the Text.
Let’s start
Text with Linear Gradient
Take a Text and use LinearGradient to give the gradient.

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
LinearGradient(gradient: Gradient(colors: [.red, .blue]), startPoint: .leading, endPoint: .trailing)
)
Text with Gradient and CornerRadius
Add cornerRadius in the above code. So your code and view should look like below.

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
LinearGradient(gradient: Gradient(colors: [.red, .blue]), startPoint: .leading, endPoint: .trailing)
.cornerRadius(10.0)
)
Text with Gradient, CornerRadius & Shadow
Add shadow in the above by adding
.shadow(color: .black, radius: 10.0, x: 0, y: 0)

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
LinearGradient(gradient: Gradient(colors: [.red, .blue]), startPoint: .leading, endPoint: .trailing)
.cornerRadius(10.0)
.shadow(color: .black, radius: 10.0, x: 0, y: 0)
)
Text with Radial Gradient, CornerRadius & Shadow.

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
RadialGradient(gradient: Gradient(colors: [.red, .blue]), center: .center, startRadius: 10, endRadius: 100)
.cornerRadius(10.0)
.shadow(color: .black, radius: 10.0, x: 0, y: 0)
)
Text with Angular Gradient, CornerRadius & Shadow.

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
AngularGradient(gradient: Gradient(colors: [.red, .yellow, .green, .blue, .purple]), center: .center, startAngle: .zero, endAngle: .degrees(360))
.cornerRadius(10.0)
.shadow(color: .black, radius: 10.0, x: 0, y: 0)
)
Text with Angular Gradient, CornerRadius, Shadow & Circle Shape

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
AngularGradient(gradient: Gradient(colors: [.red, .yellow, .green, .blue, .purple]), center: .center, startAngle: .zero, endAngle: .degrees(360))
.cornerRadius(10.0
.clipShape(Circle())
.frame(width: 200, height: 200)
.shadow(color: .black, radius: 10.0, x: 0, y: 0)
)
Text with Angular Gradient, CornerRadius, Shadow & Rectangle Shape

Text(“Anmol Maheshwari”)
.foregroundColor(.white)
.padding()
.background(
AngularGradient(gradient: Gradient(colors: [.red, .yellow, .green, .blue, .purple]), center: .center, startAngle: .zero, endAngle: .degrees(360))
.cornerRadius(10.0
.clipShape(Rectangle())
.frame(width: 200, height: 200)
.shadow(color: .black, radius: 10.0, x: 0, y: 0)
)
Gradient that masked with the Text
LinearGradient(gradient: Gradient(colors: [.red, .blue, .green,
.orange, .purple]), startPoint: .leading, endPoint: .trailing)
.mask(Text("I love my INDIA.")).font(.largeTitle)
.frame(width: 250, height: 200, alignment: .center)
)

RadialGradient(gradient: Gradient(colors: [.red, .blue, .green,
.orange, .purple]), center: .center, startRadius: 10,
endRadius: 200)
.mask(Text("I love my INDIA.")).font(.largeTitle)
.frame(width: 250, height: 200, alignment: .center)
)

AngularGradient(gradient: Gradient(colors: [.red, .blue, .green,
.orange, .purple]), center: .center, startAngle: .zero,
endAngle: .init(degrees: 360))
.mask(Text("I love my INDIA.")).font(.largeTitle)
.frame(width: 250, height: 200, alignment: .center)
)

I hope you enjoyed reading this post.
If you liked what you read, please leave some claps! and follow me.
Did I get something wrong? Mention it in the comments. I would love to improve.
Thanks
#Gradient #Linear #Radial #Rectangle #Text #Circle #Shape #iOS #XCode #SwiftUI #Developer #Technology #TechnicalAdvancement #Blogger #SwiftUIForum #MobcoderLLC