Latest 0.1.3
Homepage https://github.com/adboco/Keyboard
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

Keyboard

Version
License
Platform
Swift Version

Example

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

Requirements

  • Xcode 9.0+
  • iOS 8.0+

Installation

Keyboard is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'KeyboardSwift'

Usage

import KeyboardSwift

You can use Keyboard in UIViewController or any UIView with inputAccessoryView (UITextField, UISearchBar, UITextView). Simply call keyboard and configure it with the items you want. An example:

let cancelItem = KeyboardItem.barButton(title: "Cancel", style: .plain) { item in
    // Called when cancel item is tapped
    self.textView.endEditing(true)
}

let countLabel = UILabel()
countLabel.text = "0"
let labelItem = KeyboardItem.custom(view: countLabel)

let doneItem = KeyboardItem.barButton(title: "Done", style: .done) { item in
    // Called when done item is tapped
    self.textView.endEditing(true)
}

textView.keyboard.with(items: cancelItem, .flexibleSpace, labelItem, .flexibleSpace, doneItem)

alt text

KeyboardItem

/// Default bar button item
case barButton(title: String, style: UIBarButtonItemStyle, action: UIBarButtonItemTargetClosure?)

/// System bar button item
case systemBarButton(system: UIBarButtonSystemItem, action: UIBarButtonItemTargetClosure?)

/// Flexible space
case flexibleSpace

/// Fixed space
case fixedSpace(width: CGFloat)

/// Custom view
case custom(view: UIView)

Customize

You can customize the accessoryView calling customize method:

textView.keyboard.customize { (toolbar, items) in
    toolbar.isTranslucent = false
    toolbar.tintColor = .purple
}

Keyboard Events

Only available in UIViewController or subclass:

case willShow
case willHide
case didShow
case didHide

Example:

override func viewDidLoad() {
    super.viewDidLoad()

    // Subscribe
    self.keyboard.subscribe(to: .willShow) { sender in
        // TODO: something to do when keyboard will be shown
    }

    // ...

    // Unsubscribe
    self.keyboard.unsubscribe()
}

Author

[email protected], Adri├ín Bouza Correa

License

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

Latest podspec

{
    "name": "KeyboardSwift",
    "version": "0.1.3",
    "summary": "Keyboard makes easy to use inputAccessoryView in UIViewController, UITextView, UITextField and UISearchBar.",
    "description": "Keyboard makes easy to use inputAccessoryView in UIViewController, UITextView, UITextField and UISearchBar.",
    "homepage": "https://github.com/adboco/Keyboard",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "https://github.com/adboco"
    },
    "source": {
        "git": "https://github.com/adboco/Keyboard.git",
        "tag": "0.1.3"
    },
    "social_media_url": "https://instagram.com/adboco",
    "platforms": {
        "ios": "8.0"
    },
    "swift_version": "4.1",
    "source_files": "Keyboard/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This