можно попробовать так:
class ThirdPartyViewController: UIViewController {
var collectionView: UICollectionView!
}
class YourViewController: UIViewController, UICollectionViewDelegateFlowLayout {
let vc = ThirdPartyViewController()
var collectionView: UICollectionView { return vc.collectionView }
var originDelegate: UICollectionViewDelegateFlowLayout { return vc as! UICollectionViewDelegateFlowLayout }
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate = self
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
//return custom value
return CGSize(width: 100, height: 100)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
//return origin value
return originDelegate.collectionView!(collectionView, layout: collectionViewLayout, sizeForItemAt: indexPath)
}
}