filletofish / CardsLayout

:star: Custom card-designed CollectionView layout

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move card programatically

bubudrc opened this issue · comments

Hi, before all, awesome work.

I will like to block the user to swipe the card manually and do it programmatically, when I considere necessary, like a stepper. is this possible?

Hi! Thanks!

Yes, this is possible. One can use extension I have described in #4:

extension UICollectionView {
  func scrollToItemInCardsLayout(item: Int, animated: Bool) {
    let contentOffset = CGPoint(x: self.bounds.width * CGFloat(item), y: 0)
    self.setContentOffset(contentOffset, animated: animated)
  }
} 

To block user to swipe the cards just set collectionView.isUserInteractionEnabled

Maybe you will also interested in implementing CollectionView with infinite scrolling for stepper.

Great,

Thanks a lot for your help. One thing its that if I set collectionView.isUserInteractionEnabled = false, I can touch any button inside the cell. There are another way to stop to the user to not move the card manually?

Thanks

@bubudrc try disable the buttons or even the cells manual by changing isUserInteractionEnabled.

hmmm... what I want its to have some buttons on cells (cards) enable, and do the card animation programatically. The user should not be able to swipe the card. it's that possible?

that works perfectly... tanks a lot 😄