Skip to content

Commit

Permalink
Merge pull request #8 from takasek/uirefreshcontrol
Browse files Browse the repository at this point in the history
add extension for UIRefreshControl
  • Loading branch information
takasek authored Feb 3, 2018
2 parents 9a7dcc3 + 8d8e395 commit 6ea25ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ActionClosurable-Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
16 changes: 12 additions & 4 deletions ActionClosurable/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ extension ActionClosurable where Self: UIControl {

extension ActionClosurable where Self: UIButton {
public func onTap(_ closure: @escaping (Self) -> Void) {
convert(closure: closure, toConfiguration: {
self.addTarget($0, action: $1, for: .touchUpInside)
})
on(.touchUpInside, closure: closure)
}
}

public extension ActionClosurable where Self: UIRefreshControl {
public func onValueChanged(closure: @escaping (Self) -> Void) {
on(.valueChanged, closure: closure)
}

public init(closure: @escaping (Self) -> Void) {
self.init()
onValueChanged(closure: closure)
}
}

Expand Down Expand Up @@ -61,4 +70,3 @@ extension ActionClosurable where Self: UIBarButtonItem {
})
}
}

2 changes: 1 addition & 1 deletion ActionClosurable/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit 6ea25ec

Please sign in to comment.