AnimatedCollectionViewLayout icon indicating copy to clipboard operation
AnimatedCollectionViewLayout copied to clipboard

Scroll like animation on the click of Button

Open madBureaToT opened this issue 7 years ago • 5 comments

hey! well this works well while we have UICollectionViewCtr when we try to Customize it to ViewController By just setting flowLayout of CollectionView.

Now i have left and right button and i want the same Procedure of scroll animation on the click of these two button Action.

if any one have performed this then please help.

madBureaToT avatar Aug 09 '17 10:08 madBureaToT

var nextPage:Int = 0

@objc func clickFn(sender:UIButton){ print(nextPage) print(vcs.count)

    if(nextPage == (vcs.count-1)){
        return
    }
    nextPage += 1
    let nextItem = NSIndexPath(row: nextPage, section: 0)
    collectionView?.scrollToItem(at: nextItem as IndexPath, at: .centeredHorizontally, animated: true)
}

nohraay avatar Aug 19 '17 09:08 nohraay

ScrollToItem didn't work. Any one can help?

yonlau avatar May 18 '20 09:05 yonlau

me too. is there any update?

updev0612 avatar Nov 18 '20 12:11 updev0612

please diable pagination property

updev0612 avatar Nov 25 '20 12:11 updev0612

solution is simple. collectionView.collectionViewLayout.invalidateLayout() collectionView.scrollToItem(at: index, at: .centeredHorizontally, animated: false) This is working well.

soring323 avatar Nov 25 '20 12:11 soring323