KeyboardHost

此项目仅适用于 SwiftUI

当 View 使用 ignoresSafeAreaedgesIgnoringSafeArea(.bottom)

可以使用此框架,因为 TextFieldTextEditor 无法使键盘弹起

封装了 UITextView, UITextField 也可以使用

支持的平台

用法

    @State private var text: String = ""
    
    var body: some View {
        VStack {
            Spacer()
            KeyboardHost {
                TextField("please enter text", text: $text)
                    .frame(width: 200, height: 40, alignment: .center)
                    .padding(.bottom, 20)
            }
        }
        .ignoresSafeArea()
    }

安装

您可以将 KeyboardHost 添加到 Xcode 项目,方法是将其添加为包依赖项。

  1. 文件 菜单中,选择 Swift Packages添加 Package Dependency…
  2. 在包存储库 URL 文本字段中输入 https://github.com/HumorousGhost/KeyboardHost
  3. KeyboardHost 链接到您的应用程序目标