I am using NVActivityIndicatorView for loading animation.
I have these function to add and remove activity indicator.
func addActivityIndicator() {}
func startActivityIndicatorView() {}
func stopActivityIndicatorView() {}
I have a header which I implement in
override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let headerView = ...
return headerView
}
My problem is header is visible while collectionView is loading. I want to hide it while collectionView is loading.
You are probably performing some asynchronous operation while the indicator is animating so you should let the collection view know that the operation is finished by calling
reloadDataso it'll re-layout its UI elements including the headers viaviewForSupplementaryElementOfKind:First off, what you need is to return
CGSize.zerofromcollectionView:layout:referenceSizeForHeaderInSectionif indicator is on screen so the header won't be populated:Then wherever you hide the activity indicator (probably in the completion block of the asynchronous operation), you should call
collectionView.reloadDatasoviewForSupplementaryElementOfKindwill be called again: