Make Your Own SwiftUI Modifier

Text(“+”)

Becomes →

Text(“+”)

.myCustomStyle()

Here is how:

extension View {

  1. The public function can be further customized by passing in parameters.
  2. multiple public functions can reside in an “extension View” library. This makes it easier to customize the appearance of the app all in one place. Consequently removing the many / most of the styling info from the logic of the code into a separate file — functions as a “style sheet” library.

--

--

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