// // ContainerCollectionReusableView.swift // MVMCoreUI // // Created by Scott Pfeil on 4/7/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // import Foundation public class ContainerCollectionReusableView: UICollectionReusableView { var view: UIView? var topConstraint: NSLayoutConstraint? 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 topConstraint = view.topAnchor.constraint(equalTo: topAnchor) topConstraint?.isActive = true bottomConstraint = bottomAnchor.constraint(equalTo: view.bottomAnchor) bottomConstraint?.isActive = true rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true view.leftAnchor.constraint(equalTo: leftAnchor).isActive = true } }