vds_ios/VDS/BaseClasses/Control.swift
Matt Bruce 6b77c2829a first cut of Toggle
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-07-25 14:51:12 -05:00

63 lines
1.4 KiB
Swift

//
// Control.swift
// VDS
//
// Created by Matt Bruce on 7/22/22.
//
import Foundation
import UIKit
@objcMembers open class Control: UIControl {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
private var initialSetupPerformed = false
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: .zero)
initialSetup()
}
public init() {
super.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
fatalError("Control does not support xib.")
}
//--------------------------------------------------
// MARK: - Setup
//--------------------------------------------------
public func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
}
open func reset() {
backgroundColor = .clear
}
}
// MARK: - ViewProtocol
extension Control: ViewProtocol {
open func updateView(_ size: CGFloat) { }
/// Will be called only once.
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
}
}