Group Group Group Group Group Group Group Group Group

Colors and Gradients | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/18176818-your-first-ios-and-swiftui-app-polishing-the-app/lessons/3

Is there any reason why the alert modifier is attached to the button instead of the main VStack?

Why not using a bakground image for the button so we can have for free corner, backgroud color and gradient?

@edago You can definitely use a background image for cases like this if you want. However drawing things programmatically like this brings a few benefits:

  • App size is smaller as you’re not including images.
  • If you draw shapes programmatically they can scale up/down crisply to any size.
  • Sometimes it’s easier to draw programmatically than make everything in an image editor.

But in the end, it’s a choice for what’s right for you & your app!