Gradient in SwiftUI

Ashish Kakkad
Oct 16, 2019 · 2 min read
Image for post
Image for post

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
Image for post
Image for post

In gradient option we have to pass array of colors.

Linear Gradient

Linear Gradient have start point and end point options.

Image for post
Image for post

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.

Image for post
Image for post

Angular Gradient

In Angular Gradient we have to pass center point only.

Image for post
Image for post

Sample Code

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


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

Originally published at on October 16, 2019.

Flawless iOS

🍏 Community around iOS development, mobile design, and…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store