// // View.swift // Cyberlock // // Created by Juraldinio on 9/1/19. // Copyright © 2019 Omicronmedia. All rights reserved. // import Foundation import UIKit typealias ViewActionType = () -> Void open class View: UIView { weak var target: AnyObject? var action: ViewActionType? @available(*, unavailable) required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } init() { super.init(frame: .zero) setup() } override init(frame frameRect: CGRect) { super.init(frame: frameRect) setup() } func setup() { addSubviews() addConstraints() let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.onTapGesture)) self.addGestureRecognizer(tapGesture) } func addSubviews() { } func addConstraints() { } @objc private func onTapGesture() { guard let action = self.action else { return } action() } }