Swiftpack.co - takasek/ActionClosurable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by takasek.
takasek/ActionClosurable 2.1.0
Extensions which helps to convert objc-style target/action to swifty closures
⭐️ 124
🕓 4 years ago
.package(url: "https://github.com/takasek/ActionClosurable.git", from: "2.1.0")

ActionClosurable

Version License Platform Carthage Compatible

Usage

ActionClosurable extends UIControl, UIButton, UIRefreshControl, UIGestureRecognizer and UIBarButtonItem. It helps writing swifty code with closure, instead of target and action like below:

// UIControl
button.on(.touchDown) {
    $0.backgroundColor = UIColor.redColor()
}
button.on(.touchUpOutside) {
    $0.backgroundColor = UIColor.whiteColor()
}
// UIButton
button.onTap {
    $0.enabled = false
}

// UIRefreshControl
tableView.refreshControl = UIRefreshControl { refreshControl in
    DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
        refreshControl.endRefreshing()
    }
}

// UIGestureRecognizer
label.addGestureRecognizer(UIPanGestureRecognizer { (gr) in
    print("UIPanGestureRecognizer fire")
})

// UIBarButtonItem
let barButtonItem = UIBarButtonItem(title: "title", style: .plain) { _ in
    print("barButtonItem title")
}

// And you can easily extend any NSObject subclasses!

And you can extend any NSObject subclasses in very easy way. Refer to the source.

Installation

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

pod "ActionClosurable"

ActionClosurable is available through Carthage. To install it, simply add the following line to your Cartfile:

github "takasek/ActionClosurable"

ActionClosurable is available through Swift Package Manager. To install it, add dependency in Package.swift:

let package = Package(
    ...
    dependencies: [
         .package(url: "[email protected]:takasek/ActionClosurable.git", from: "2.1.0"),
    ],
    ...
)

Author

takasek

License

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

GitHub

link
Stars: 124
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swift Package Manager
4 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics