Files
Attractor/App/Utilities/LayoutLatch.swift

31 lines
574 B
Swift
Raw Permalink Normal View History

2023-08-10 19:52:59 -07:00
//
// LayoutLatch.swift
// App
//
// Created by James Magahern on 8/10/23.
//
import Foundation
class LayoutLatch {
public weak var view: UIView?
public private(set) var latched: Bool = false
init(_ view: UIView) {
self.view = view
}
public func activate() {
latched = true
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [weak self] in
self?.deactivate()
}
}
public func deactivate() {
latched = false
view?.setNeedsLayout()
}
}