Gradient in SwiftUI

SwiftUI comes with easiest way of coding!

In SwiftUI they have given 3 types of gradients, you can easily show gradients on any of the view.

  1. Linear Gradient
  2. Radial Gradient
  3. Angular Gradient
SwiftUI with Gradient

In gradient option we have to pass array of colors.

Linear Gradient

Linear Gradient have start point and end point options.

Radial Gradient

In Radial Gradient we have to specify start radius point, end radius point with center point from where the radial gradient will start.

Angular Gradient

In Angular Gradient we have to pass center point only.

Sample Code

Here is sample code of “SwiftUI with Gradient” the output of which is shown at the beginning of the post.

Conclusion

SwiftUI is comes with lot of things to learn. Keep Learning!
Happy Coding 🙂