组件Components
TextFieldTextField
轻量文本输入组件,适合表单、搜索和设置项。A lightweight text input for forms, search, and settings.
入门Beginner • 4 分钟4 min
更新于Updated Apr 22, 2026
基础输入Basic Input
TextField 通过双向绑定接收用户输入,通常和 @State 配合使用。TextField receives user input through two-way binding, often paired with @State.
简单 TextFieldSimple TextField
swift
1@State private var email = ""23TextField("Email", text: $email)4 .textInputAutocapitalization(.never)5 .keyboardType(.emailAddress)6 .textFieldStyle(.roundedBorder)
输入相关 modifierInput Modifiers
promptprompt
占位提示Placeholder
keyboardTypekeyboardType
键盘类型Keyboard type
submitLabelsubmitLabel
回车按钮文案Return key label
textInputAutocapitalizationtextInputAutocapitalization
自动大小写策略Autocapitalization strategy