Files
2021-06-03 17:59:25 +06:00

52 lines
1.0 KiB
Swift

//
// 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()
}
}