【发布时间】:2021-01-05 18:41:06
【问题描述】:
TextEditor 有问题,在 TextEditor 上编辑文本后无法隐藏键盘。
@State var monTexte: String = "
var body: some View {
VStack {
Spacer()
.frame(height :15)
.clipped()
Text("Project ")
.font(Font.system(size: 39.00))
.fontWeight(.black)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.padding(.all, 16.0)
.clipped()
TextEditor(text: $monTexte)
.keyboardType(.alphabet)
.font(.subheadline)
.padding(.horizontal)
.font(Font.system(size: 38.00))
.frame(minWidth: 10, maxWidth: .infinity, minHeight: 10, maxHeight: 200, alignment: .topLeading)
.border(Color.black)
.clipped()
}
}
}
我找到了一种使用文本字段而不是使用 TextEditor 来隐藏键盘的方法 请你帮帮我吧
【问题讨论】:
-
如何定义编辑后的时刻,即。您想在哪个事件中隐藏键盘?
-
用特定按钮或使用键盘上的回车键(例如),但没有找到隐藏键盘的功能
-
TextEditor 中的Keybord Return 会生成新行(它不是TextField),但对于某些按钮,您可以使用stackoverflow.com/questions/58349955/… 中的方法。
标签: swiftui text-editor