New App - Constants

When starting a new app, it’s important to set the constants that will be shared across the app correcly:

Colors

  • Create a new asset catalog where you will place your colors. Ideally, use the exact same names as your designers, and provide light/dark mode variations.
  • In the build settings of the project, set the Global Accent Color Name to the primary color of your app.

Then you can create a simple file for representing your colors:

Using the namespaces, you can then be very clear in your code:




Spacing

The same concept applies for Spacing constants, we can create a simple extension of CGFloat:




Sources:

New App - Constants | manu.show
Tags: iOS
Share: X (Twitter) LinkedIn