【发布时间】:2019-07-22 21:57:20
【问题描述】:
有谁知道如何自定义 SwiftUI TextField 属性,例如 spellCheckingType 或 autocorrectionType? 在不与 UIKit 交互的情况下做到这一点似乎是不可能的......
谢谢大家!
【问题讨论】:
有谁知道如何自定义 SwiftUI TextField 属性,例如 spellCheckingType 或 autocorrectionType? 在不与 UIKit 交互的情况下做到这一点似乎是不可能的......
谢谢大家!
【问题讨论】:
对于TextField或Text的AutoCorrection,你可以试试
struct ContentView: View {
@State private var name: String = "Angie"
var body: some View {
VStack {
TextField("Enter your name", text: $name)
Text("Hello, \(name)!")
}
.disableAutocorrection(true)
}
}
我不确定 SwiftUI 中的拼写检查,但您可以查看 https://developer.apple.com/documentation/swiftui/textfield 进行修改。
希望对您自定义TextField有所帮助!
谢谢!!
【讨论】: