AccessoryKit

A customizable, expandable, and easy-to-use input accessory view component for iOS.


Keywords
accessoryview, inputaccessoryview, ios, ipados, swift, ui
License
MIT
Install
pod try AccessoryKit

Documentation

AccessoryKit

A customizable, expandable, and easy-to-use input accessory view component for iOS.

Version License Platform

Features

AccessoryKit aims to provide a customizable, expandable and easy-to-use input accessory view. This component is developed for and is currently used in my app MDNotes.

The main features are:

  • Scrollable input accessory view with blurry background and customizable buttons.
  • Supports Auto Layout and Safe Area.
  • Supports dark mode.
  • Provides built-in pre-defined buttons with Google Material Icon or SF Symbol.

Usage

Requirements

  • iOS 10.0+
  • Swift 5.0+

Installation

To install AccessoryKit, simply add the following line to your Podfile:

pod 'AccessoryKit'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

API

// Create view model array of key buttons
let keyButtons: [KeyboardAccessoryButton] = [
    KeyboardAccessoryButton(type: .undo, tapHandler: { [weak self] in
        self?.undo()
    }),
    KeyboardAccessoryButton(image: UIImage(named: "img", tapHandler: {}),
]

// 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)

TODO

  • Expose more APIs customization
  • Tint color
  • Tweak UI
  • Use SF Symbol

License

AccessoryKit is available under the MIT license. See the LICENSE file for more info.