Swift/UIKit/UICollectionView Custom Header disappear animation Custom

17 views Asked by At

Hi I am studying iOS and I am making my own weatherApp with WeatherKit. I want to make Same View with Basic WeatherApp in iphone

These are my question

  1. how to make my custom header disappear with custom Animation?(ex apple WeatherApp)
  2. I am making it with two UICollectionReusableView and I am using like this

`func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

    guard kind == UICollectionView.elementKindSectionHeader,
          let firstHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind,
                                                                       withReuseIdentifier: CollectionFirstHeader.identifier,
                                                                       for: indexPath)  as? CollectionFirstHeader,
          let secondHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind,
                                                                             withReuseIdentifier: CollectionSecondHeader.identifier,
                                                                             for: indexPath)  as? CollectionSecondHeader
    else { return UICollectionReusableView()}
    firstHeader.section = indexPath.section
    secondHeader.section = indexPath.section
    switch indexPath.section {
    case 0, 1, 2:
        return firstHeader
    case 3,4:
        return secondHeader
    default:
        return firstHeader
    }
}`

And with this code, First Header keep showing above the second header. How can I handle it?

I guess that Using multiple reusableView is not recommended.

0

There are 0 answers