# TextField ⟩ styles

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="info" %}
.[textFieldStyle(\_:)](https://swiftontap.com/view/textfieldstyle\(_:\)) 方法不是只能用在 TextField 上，它也可以用在 parent view 上面❗️
{% endhint %}

```swift
// ⭐️ parent view 使用 .textFieldStyle() 才不會失去 context。
view.textFieldStyle(.roundedBorder)

// ⭐️ text field 可使用 custom method，使語意更簡潔。
textField.style(.roundedBorder)    // custom method
```

👉 see: [textfield-+-style](https://lochiwei.gitbook.io/ios/swiftui/control/textfield/styles/textfield-+-style "mention")
{% endtab %}

{% tab title="📘 手冊" %}

* [SwiftUI](https://developer.apple.com/documentation/swiftui) ⟩ [Views and Controls](https://developer.apple.com/documentation/swiftui/views-and-controls) ⟩ [TextField](https://developer.apple.com/documentation/swiftui/textfield) ⟩&#x20;
  * [TextFieldStyle](https://developer.apple.com/documentation/swiftui/textfieldstyle)
  * textField.[textFieldStyle(\_:)](https://developer.apple.com/documentation/swiftui/view/textfieldstyle\(_:\))&#x20;
* SwiftOnTap ⟩&#x20;
  * [TextFieldStyle](https://swiftontap.com/textfieldstyle) (<mark style="color:red;">**protocol**</mark>)
  * view.[textFieldStyle(\_:)](https://swiftontap.com/view/textfieldstyle\(_:\))&#x20;
    {% endtab %}

{% tab title="📗 參考" %}

* [ ] Sundell ⟩ [Encapsulating SwiftUI view styles](https://www.swiftbysundell.com/articles/encapsulating-swiftui-view-styles/)&#x20;
  {% endtab %}
  {% endtabs %}
