以下代码,仅在Swift + SwiftUI开发的应用上测试过。 如下图所示,关闭或隐藏键盘 解决方案// 发送回车事件 let el_keyboard = app.keyboards.element if el_keyboard.exists { app.typeText("\n") }