6

UICollectionViewCell のサイズ変更をアニメーション化したいと思います。以下のコードを書きましたがreturn、アニメーション ブロック内に行を含めることができません。何か案は?

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {

    var newSize = CGSize(width: (self.view.frame.width), height: 0)


    UIView.animateWithDuration(2.0, animations: { () -> Void in
        return newSize
    })

}
4

1 に答える 1

2

アニメーションさせたい場合は以下のメソッドを呼び出し、

self.collectionView.performBatchUpdates(updates: (() -> Void), completion:((Bool) -> Void)?)

より具体的には、以下のように向きの変更も処理する必要があります。

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation)
{
    self.collectionView.performBatchUpdates(nil, completion: nil)

}
于 2016-05-31T11:18:37.830 に答える