title: SwiftUI: How to add custom modifier for Text
body: <p>So far, I am able to write custom modifiers for Views; however, when trying to keep my code DRY, I am trying to add a custom modifier for TextFields. The view modifiers work great with something like so:</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct sampleModifier : ViewModifier {
      var height: CGFloat? = 100
      func body(content: Content) -&gt; some View {
          content
              .frame(height: height)
              .background(Color.white)
              .border(Color.gray, width: 0.5)
              .shadow(color: Color.black, radius: 15, x: 0, y: 10)
      }
  }
  </code></pre>
  
  <p>But when I try to use modifiers like <code>font</code> and so, it shows a lot of errors. I do understand that they might need to be more specific and instead conform to the <code>TextFieldStyleModifier</code>, but I do not get how to make it work. I have tried to do it this way without success:</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct TitleModifier : TextFieldStyleModifier {
      func body(content: TextFieldStyle) -&gt; some View {
          content
              .font(.custom("Open Sans", size: 18))
              .color(Color.green)
  
      }
  }
  </code></pre>
  
  <p>Which obviously fails and shows the following error:
  <a href="https://i.stack.imgur.com/cpgG0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cpgG0.png" alt="Error"></a></p>
  
  <p>If I click on the <code>Fix</code> suggestion, it adds this to my code</p>
  
  <pre class="lang-swift prettyprint-override"><code>TextFieldStyleModifier&lt;&lt;#Style: TextFieldStyle#&gt;&gt;
  </code></pre>
  
  <p>Which I do not know how to use.</p>
  
  <p>Any suggestions?</p>