I have a subclass of UIControl
which contains (and controls) a UICollectionView
. I'm trying to get it to auto-resize to fit the collectionView, but haven't had any success yet.
The collection view is set up in a common init method of the UIControl
subclass as follows:
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumInteritemSpacing = 0
layout.itemSize = CGSize(width: 30, height: 30)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.isUserInteractionEnabled = false
collectionView.isScrollEnabled = false
collectionView.delegate = self
collectionView.dataSource = self
addSubview(collectionView)
If anyone could help with this, I'd greatly appreciate it! Thanks in advance.