2

In the Facebook app they have a collection View at the top for stories. When a user taps on a cell there is a slight depression and then back, this begins happening before the user even lifts his finger off the cell.

How could I achieve this effect? For the sake of simplicity I would like to know how to highlight that cell.

Update:

Something I realized is that currently when a user taps down on a cell the text labels in it disappear, how can I know where this is happening so I can animate other things?

update 2:

I was able to get close with the following:

@objc private func cellLongPressHandler(_ sender: UILongPressGestureRecognizer) {

    print("TOUCH DOWN")
    // handle touch down and touch up events separately

    if sender.state == .began {


    } else if  sender.state == .ended {

    }

}

And then:

  cell.addGestureRecognizer(cellLongPressGesture) //new jun 16

The issue however is that when this is added, the collection View is made un-swipable and thus unusable. How can I fix this?

  • You want to detect a touchDown. Some ideas here: https://stackoverflow.com/questions/19611601/ios-detect-tap-down-and-touch-up-of-a-uiview – Lou Franco Jun 16 '19 at 23:00

1 Answers1

4

Use these methods: SWIFT 4

func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {

}