【发布时间】:2021-12-27 03:23:29
【问题描述】:
我想实现在 SecureField 中显示和隐藏密码的功能。 下面是 SecureField 的代码 我添加了按钮,该按钮将被检测到以显示和隐藏 SecureField 中的文本。 但是 swiftUI 没有类似 isSecureTextEntry 的功能 除了在 Textfield 和 SecureField here
之间切换还有其他方法吗SecureField(placeholder, text: $textValue, onCommit: {
onReturn?()
})
.onTapGesture {
onBegin?()
}
.keyboardType(keyboardType)
.font(Font.label.bodyDefault)
.disableAutocorrection(true)
.frame(maxWidth: .infinity, maxHeight: 40)
.padding(.leading)
【问题讨论】:
-
链接选项是最好的选择,除非你想进入比这复杂得多的
UIViewRepresentable。
标签: swiftui securefield