Skip to content

Instantly share code, notes, and snippets.

View tarangpatel's full-sized avatar

Tarang Patel tarangpatel

View GitHub Profile
@tarangpatel
tarangpatel / ActionButton.swift
Created January 31, 2018 14:15
[Custom UIButton with closure] #customUI #UIButton
//https://stackoverflow.com/a/38086405/484605
class ActionButton: UIButton {
var touchDown: ((button: UIButton) -> ())?
var touchExit: ((button: UIButton) -> ())?
var touchUp: ((button: UIButton) -> ())?
required init?(coder aDecoder: NSCoder) { fatalError("init(coder:)") }
override init(frame: CGRect) {
super.init(frame: frame)
@tarangpatel
tarangpatel / ControlClosure.swift
Last active January 31, 2018 14:16
[UIControl Extension Handle Closure] #UIButton #UIControl #extension
//https://stackoverflow.com/a/41438789/484605
class ControlClosure {
let closure: ()->()
init (_ closure: @escaping ()->()) {
self.closure = closure
}
@objc func invoke () {
@tarangpatel
tarangpatel / SearchBar.swift
Last active March 28, 2020 17:41
[Throttling] #throttling #SearchBar
import UIKit
public class SearchBar: UISearchBar, UISearchBarDelegate {
/// Throttle engine
private var throttler: Throttler? = nil
/// Throttling interval
public var throttlingInterval: Double? = 0 {
didSet {