mvm_core_ui/MVMCoreUI/BaseClasses/CollectionView.swift
Pfeil, Scott Robert 5ce98da559 improvements
2020-04-10 16:59:40 -04:00

47 lines
1.2 KiB
Swift

//
// CollectionView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 4/10/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class CollectionView: UICollectionView, MVMCoreViewProtocol {
private var initialSetupPerformed = false
private func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
}
public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
initialSetup()
}
required public init?(coder: NSCoder) {
super.init(coder: coder)
initialSetup()
}
public func updateView(_ size: CGFloat) {
for cell in visibleCells {
(cell as? MVMCoreViewProtocol)?.updateView(size)
}
collectionViewLayout.invalidateLayout()
}
public func setupView() {
translatesAutoresizingMaskIntoConstraints = false
showsHorizontalScrollIndicator = false
backgroundColor = .clear
isAccessibilityElement = false
contentInsetAdjustmentBehavior = .always
}
}