Latest 1.0.0
Homepage https://github.com/daaavid/SwiftHandlerKit
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

Super lightweight library (83 lines) to assign closure-based actions to UIControls and the like.

CI Status
Version
License
Platform

Usage

Just use the fuction .on, followed by the event on any UIControl to assign an action for that event.

textField.on(.editingChanged) { textField in
  // no need to cast as UITextField
  print("editingChanged", textField.text!)
}
button.on(.touchUpInside, .touchUpOutside) { button in
  //multiple events
  UIView.animate(withDuration: 0.15) {
    button.transform = .identity
  }
}

There’s also some support for UIBarButtonItems.

navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back") { barButtonItem in
  print("leftBarButtonItemWasPressed")
}

Example

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

Requirements

Installation

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

pod 'SwiftHandlerKit'

If you get some sort of spec error, try pod repo update or:

pod 'SwiftHandlerKit', :git => 'https://github.com/daaavid/SwiftHandlerKit.git', :branch => 'master'

Author

daaavid, [email protected]

License

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

Latest podspec

{
    "name": "SwiftHandlerKit",
    "version": "1.0.0",
    "summary": "Elegantly assign closure-based actions to UIControls and the like.",
    "homepage": "https://github.com/daaavid/SwiftHandlerKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "David Johnson": "[email protected]"
    },
    "source": {
        "git": "https://github.com/daaavid/SwiftHandlerKit.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftHandlerKit/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This