0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【SwiftUI】よくある TextField を作る

Last updated at Posted at 2024-05-08

こう書いてみました。

RoundedBorderTextField(label: "Search", text: $text)
  .frame(width: 200)

sc 2024-05-08 at 14.44.38.png

struct RoundedBorderTextField: View {
  var label: String
  @Binding var text: String

  private let rect = RoundedRectangle.rect(cornerRadius: 6)

  var body: some View {
    TextField(label, text: $text)
      .textFieldStyle(.plain)
      .padding(6)
      .background(.background, in: rect)
      .overlay(rect.stroke(.secondary, lineWidth: 0.5))
  }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?