// // InfoHeaderCollectionReusableView.swift // Wallet // // Created by Saveliy Stavitsky on 8/28/20. // Copyright © 2020 List. All rights reserved. // import UIKit import MessageKit class InfoHeaderCollectionReusableView: MessageReusableView { override init(frame: CGRect) { super.init(frame: frame) xibSetup() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) xibSetup() } func xibSetup() { let contentView = loadViewFromNib() // use bounds not frame or it'll be offset contentView.frame = bounds // Make the view stretch with containing view contentView.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight] // Adding custom subview on top of our view (over any custom drawing > see note below) addSubview(contentView) } func loadViewFromNib() -> UIView { let bundle = Bundle(for: type(of: self)) let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle) let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView // swiftlint:disable:this force_cast return view } }