SwiftUI 中的 textarea 相当于什么?我可以在其中输入多行文本。并指定该区域的大小?HTML 示例在这里: https: //www.w3schools.com/tags/tryit.asp ?filename=tryhtml_textarea 我已经搜索了很多,但没有任何运气。
我尝试在 SwiftUI 中使用 TextField,但如果用户编写长文本,文本就会超出屏幕。
TextField("notes")
.background(Color.yellow)
.lineLimit(3)
Run Code Online (Sandbox Code Playgroud)
Răz*_*oiu 19
SwiftUI 中 TextArea 的等价物是 TextEditor。Apple 于 2020 年中期推出
var body: some View {
TextEditor(text: $profileText)
.foregroundColor(.black)
}
Run Code Online (Sandbox Code Playgroud)
这是更详细描述它的参考:https://www.hackingwithswift.com/quick-start/swiftui/how-to-create-multi-line-editable-text-with-texteditor
| 归档时间: |
|
| 查看次数: |
9906 次 |
| 最近记录: |