Im trying to make a gesture or double tap on a cell in my collection view to open modal view

I making a calendar view and I want to be able to make a modal view display when the user double taps or long press a cell. How would I add this feature?

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell=collectionView.cellForItem(at: indexPath)
cell?.backgroundColor=Colors.blue
let lbl = cell?.subviews[1] as! UILabel
lbl.textColor=UIColor.white
}

func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
    let cell=collectionView.cellForItem(at: indexPath)
    cell?.backgroundColor=UIColor.clear
    let lbl = cell?.subviews[1] as! UILabel
    lbl.textColor = Style.activeCellLblColor
}

Probably better asked over at the Apple Developer forums, StackOverflow, etc.. The question is about Apple frameworks, and could be asked about an Objective-C implementation. Not specific to the Swift language.

Terms of Service

Privacy Policy

Cookie Policy