mvm_core_ui/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift
2020-04-22 21:17:57 -04:00

28 lines
962 B
Swift

//
// ContainerCollectionReusableView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 4/7/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
/// CollectionReusableView that can contains any other view.
public class ContainerCollectionReusableView: UICollectionReusableView {
public var view: UIView?
public var topConstraint: NSLayoutConstraint?
public var bottomConstraint: NSLayoutConstraint?
public func addAndContain(view: UIView) {
guard self.view != view else { return }
self.view?.removeFromSuperview()
view.setContentCompressionResistancePriority(.required, for: .vertical)
addSubview(view)
self.view = view
let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: view)
topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint
bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint
}
}