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.
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
}
}
}
}