由于Swiftui原生未提供该修饰符
需要用到Uikit的代码:然后在任意View里面就可以调用hideKeyBoard了。
-
#
if canImport(
UIKit)
-
extension View {
-
func hideKeyboard() {
-
UIApplication.shared.sendAction(#selector(
UIResponder.resignFirstResponder), to:
nil, from:
nil,
for:
nil)
-
}
-
}
-
#endif
转载:https://blog.csdn.net/u010913414/article/details/109396888
查看评论