Latest 0.0.4
License MIT
Platforms ios 8.0, requires ARC

UIClosures CocoaPod Carthage compatible MIT license [Issues](

by ark. tweet @arkverse for any feature requests. Feedback is greatly appreciated!


A Swift closure library for UIKit that makes events significantly easier and cleaner. Currently supports closures on UIControl events and UIGestureRecognizers (all subclasses). We will be adding more closure support as we go along. Memory managed and written completely in Swift.

All the UIControlEvents are supported, and multiple closures can be added to the same event.

Quick example:

button.on(.TouchUpInside, (sender: AnyObject) -> () {
    let button = sender as! UIButton
    button.setTitle("Pressed", forControlState:.Normal)

Be sure to check out our SwiftRecord library too!

Visit ark for a more beginner friendly guide to UIClosures

If you love UIClosures, tweet it!
<img src=""
alt="tweet button" title="UIClosures">


via CocoaPods

  1. Edit your Podfile to use frameworks and add UIClosures:

    platform :ios, '8.0'
    pod 'UIClosures', '~> 0.0.2'
  2. run pod install

via Carthage

  1. Just add UIClosures to your Cartfile:

    github "arkverse/UIClosures" >= 0.0.2
  2. and run carthage update

Manual Installation

Drag and drop either Classes/UIClosures.swift or UIClosures.framework into your project



  1. import UIClosures into your file (if needed)
  2. call on on your UIControl or one of the convenience methods like onTouchUpInside

    // Make sure you set your capture list to break your class-closure strong reference loop
    on(.TouchUpInside, listener: { [unowned self] (sender) -> () in
        self.title = "New ViewController Title!"
        let button = sender as! UIButton
        button.titleLabel?.font = UIFont.systemFont
    // Can add another closure to the same event, convenience method used here
    button.onTouchUpInside() {[weak button = button] (sender) -> () in
        button.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
  3. Note that you most likely need your capture list for each closure


Use any of the subclasses you want. You must use the closure initializer and not the target: action: initializer:

let tap = UITapGestureRecognizer() { (gesture: UITapGestureRecognizer) -> () in
    println("got a tap")

tap.onGesture() { (gesture: UITapGestureRecognizer) -> () in
    println("got this tap again")

Will call all of your closures

Again, remember your capture list if referring to any variables


  • add more closures
  • testing


UIClosures is available under the MIT license. See the LICENSE file
for more information.

Check out ark for more about us and check out our other Swift libraries

ga tracker

Latest podspec

    "name": "UIClosures",
    "version": "0.0.4",
    "summary": "Swift closure library for UIKit",
    "description": "Closure based UI events. Supports UIControls and UIGestureRecognizers. Written purely in Swift and memory managed. Cheers",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Zaid Daghestani": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "v0.0.4"
    "source_files": [
    "requires_arc": true

Pin It on Pinterest

Share This