Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Swift more than one behaviour in the same UICollectionView

I add a custom collectionViewLayout to CollectionView. I have 6 cells and I pass the next item with default animation style. But when I pass the last cell I want to make an animation as PageAnimation(custom). I add the collectionViewLayout in the viewDidLoad but it effects all cells.

let layout = AnimatedCollectionViewLayout()
layout.animator = PageAttributesAnimator()
layout.scrollDirection = .horizontal
collectionView.collectionViewLayout = layout

How can I use 2 different layout types in one CollectionView ?

Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        for cell: UICollectionViewCell in clcView.visibleCells {
            let indexPath: IndexPath? = clcView.indexPath(for: cell)
            if let indexPath = indexPath {
                print("\(indexPath)")
                if indexPath.row >= 2 {
                    let layout = AnimatedCollectionViewLayout()
                    layout.animator = PageAttributesAnimator()
                    layout.scrollDirection = .horizontal
                    clcView.collectionViewLayout = layout
                }
                else {
                    let layout = AnimatedCollectionViewLayout()
                    layout.animator = RotateInOutAttributesAnimator()
                    layout.scrollDirection = .horizontal
                    clcView.collectionViewLayout = layout
                }
            }
        }
    }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!