Member-only story
Angular Gradient in SwiftUI
AngularGradient view in SwiftUI was introduced with iOS 13 and is used to draw an angular gradient. This view conforms to ShapeStyle protocol.
For the simplest initializer AngularGradient takes colors as a parameter along with UnitPoint for the location of center as shown below:
struct AngularGradientExample: View {
let colors = [Color.blue, .purple, .cyan, .teal, .green, .orange, .pink, .red]
var body: some View {
AngularGradient(colors: colors, center: .center)
.edgesIgnoringSafeArea(.all)
}
}We can move center by changing the value for center.
struct AngularGradientExample: View {
let colors = [Color.blue, .purple, .cyan, .teal, .green, .orange, .pink, .red]
var body: some View {
AngularGradient(colors: colors, center: .topLeading)
.edgesIgnoringSafeArea(.all)
}
}Instead of typing all enum values for UnitPoint, we will animate between them.
struct…







