当有人触摸UICollesctionView的Cell时,有人能指出正确的方向吗?我读过didSelectItemAt与UIView.Animate或willDisplayCell与CAAnimations之间有几种方法。有人可以指点我在Swift的正确方向吗?目标是点击单元格并使其缩放/更改x位置
答案 0 :(得分:0)
我会选择" didSelectItemAt",用" UIView.animate"
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
let cell = collectionView.cellForItem(at: indexPath)
animatedImage = UIImageView(frame: cell.frame)
animatedImage.image = ...
view.addSubview(animatedImage)
UIView.animate(withDuration: 0.5, animations: {
self.animatedImage.frame = self.view.bounds
self.view.layoutIfNeeded()
}, completion: {(finished) in
...
})
}