2016-12-23 6 views
2

タッチしたときにUICollesctionViewのセルをアニメーション化する方法について、誰かが正しい方向に向けるでしょうか?私は、UIView.AnimateでdidSelectItemAtとCAAnimationsでwillDisplayCellの間にいくつかのメソッドがあると読んでいます。誰かがSwiftの正しい方向に私を向けることができますか?目標は、セルをタップすると、それは私が「didSelectItemAt」を選択します/変更x位置UICollectionViewタッチ時にアニメ化する

+0

ファクトリメソッドがobj-Cであるが、Xcodeのことですあなたをスウィフトの正しい方向に向けるべきです。 http://stackoverflow.com/a/22487238/4475605 – Adrian

答えて

1

をスケーリング持って、「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 
      ... 
     }) 
} 
関連する問題