SwiftUI Custom View Modifiers
Dec 26, 2021
We can create custom view modifiers if we want to reuse them in multiple views. Example:
Here, we have TitleModifier custom modifier and we use it in MyView to customize a text:
To make it prettier we can add custom modifier as an extension on Text:
Now we can use the modifier like native SwiftUI modifiers: