【发布时间】:2020-10-11 20:38:12
【问题描述】:
我想在我的CustomCollectionViewCell 上添加一个tapAnimation,所以我在class 中添加了这些行:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
UIView.animate(withDuration: 0.05, delay: 0, options: .curveEaseInOut) {
self.theView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
UIView.animate(withDuration: 0.1, delay: 0, options: .curveEaseInOut) {
self.theView.transform = CGAffineTransform(scaleX: 1, y: 1)
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
UIView.animate(withDuration: 0.1) {
self.theView.transform = CGAffineTransform(scaleX: 1, y: 1)
}
}
theView 几乎就是这里的整个cell。但是,添加此内容后,我的collectionView 中的didSelectItemAt 不再触发。知道我在这里做错了什么吗?它可以在没有override-sn-ps 的情况下工作。
补充:我实际上希望有一个像 App-Store 一样的动画(只有点击动画,没有过渡!)
如果您需要更多信息,请告诉我!
【问题讨论】:
标签: ios swift uicollectionview uicollectionviewcell