AccessoryKit 2.0.1

AccessoryKit 2.0.1

Yubo Qin 维护。



  • Yubo Qin

AccessoryKit

一个可定制、可扩展且易于使用的 iOS 输入工具栏视图组件。

Version License Platform

特性

AccessoryKit旨在提供可定制、可扩展且易于使用的输入工具栏视图。该组件是为我的应用开发的,目前正在我应用MDNotes中使用。

主要特性包括

  • 带模糊背景和可定制按钮的可滚动输入工具栏视图。
  • 支持自动布局和安全区域。
  • 支持深色模式。
  • 提供带有 SF Symbol 的内置预定义按钮。
  • 支持在输入工具栏视图上呈现 UIMenu

用法

要求

  • iOS 13.0+
  • Swift 5.3+

安装

要安装 AccessoryKit,只需将以下行添加到您的 Podfile 中

pod 'AccessoryKit'

示例

要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install

API

// Create view model array of key buttons
let keyButtons: [KeyboardAccessoryButton] = [
    // Create button with built-in type and tap handler block
    KeyboardAccessoryButton(type: .undo, tapHandler: { [weak self] in
        self?.undo()
    }),
    // Create button with UIImage
    KeyboardAccessoryButton(image: UIImage(named: "img"), tapHandler: {}),
    // Create button with UIMenu
    KeyboardAccessoryButton(type: .link, menu: createInsertMenu()),
]

// Initialize `KeyboardAccessoryView`
let accessoryView = KeyboardAccessoryView(
    frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 0),
    keyButtons: keyButtons,
    showDismissKeyboardKey: true,
    delegate: self)

// Assign the accessory view instance to `UITextView`
textView.inputAccessoryView = accessoryView

// Set tint color for the whole view
accessoryView.tintColor = .systemPink
// ...or at a given index
accessoryView.setTintColor(.systemGreen, at: 5)

// Set enabled at a given index
accessoryView.setEnabled(false, at: 1)

待办事项

  • 更多 API 以便自定义
  • 色调颜色
  • 调整 UI
  • 使用 SF Symbol
  • 支持 UIMenu
  • 支持 UIAction
  • 支持 SPM

许可证

AccessoryKit 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。