19 lines
497 B
Swift
19 lines
497 B
Swift
import UIKit
|
|
|
|
class ActionButton: UIButton {
|
|
var actionHandler: (() -> Void)? {
|
|
didSet {
|
|
self.removeTarget(self, action: #selector(self.actionImpl), for: .touchUpInside)
|
|
self.addTarget(self, action: #selector(self.actionImpl), for: .touchUpInside)
|
|
}
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
@objc private func actionImpl() -> Void {
|
|
self.actionHandler?()
|
|
}
|
|
}
|