Make Your Own SwiftUI Modifier

I Learn faster by Example

SwiftUI comes with a set of built-in view modifiers, for example. “.padding()”, that can be added toe Image, Text etc to request more space between views. Once we start to use these modifiers, they stack up and become cumbersome: It is inconvenient to copy-paste a large collection of them to reproduce the same look for similar elements in different part of the code.

This is where making our own custom view modifier becomes useful. For example: