title: Making a custom SwiftUI View adapt to built-in modifiers
body: <p>I am endeavouring to write my own <code>BetterTextField</code> view for SwiftUI, since the built-in <code>TextField</code> is lacking in several areas. Namely, I want to support delayed binding (updating the bound value only on locusing focus, instead of forcing redraws after every keypress), programmatic focusing/responder control, and a few other features of UIKit's <code>UITextField</code> that SwiftUI lacks.</p>
  
  <p>So I've created a custom <code>UIViewRepresentable</code> with a coordinator as the <code>UITextFieldDelegate</code> and that's working fine. However, for parity with other views, I'd really like to have my custom text field adapt to certain existing SwiftUI modifiers.</p>
  
  <p>For example:</p>
  
  <pre><code>// Here's my content view
  struct ContentView: View {
      var body: some View {
          BetterTextField("Username", text: $username)
              // I want to adapt the view to this modifier
              .textFieldStyle(RoundedBorderTextFieldStyle())
      }
  }
  
  // Here's my (simplified) custom text field view
  struct BetterTextField: UIViewRepresentable {
      var title: String
      @Binding var text: String
  
      init(_ title: String, text: Binding&lt;String&gt;) {
          self.title = title
          self._text = text
      }
  
      func makeUIView(context: Context) -&gt; UITextField {
          let textField = UITextField()
          textField.placeholder = title
          return textField
      }
  
      func updateUIView(_ view: UITextField, context: Context) {
          view.text = text
  
          // How can I check for the .textFieldStyle() modifier here and set the corresponding UIKit style accordingly?
          view.borderStyle = .roundedRect
      }
  }
  </code></pre>
  
  <p>As the comment says, how can I adapt the <code>borderStyle</code> property of my <code>UITextField</code> to match the View modifier?</p>
  
  <p>And more generally, how does one check for the presence of modifiers and return the appropriately-styled custom view (such as <code>.bold()</code> translating to attributed text, perhaps)?</p>