2

performBatchUpdates を介して行われるアニメーションのタイミングをカスタマイズする方法はありますか?

私はこのコードを持っています

[self.stepCollectionView performBatchUpdates:^{
    self.stepSelectedIndex = indexPath.row;

    UICollectionViewCell *cell = [self.stepCollectionView cellForItemAtIndexPath:indexPath];

    [UIView transitionWithView:cell
                      duration:0.5f
                       options: UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionBeginFromCurrentState
                    animations:^{
                        CGRect frame = cell.frame;
                        frame.size.height = 416;
                        cell.frame = frame;
                    }
                    completion:^(BOOL finished) {
                    }];
    } completion:^(BOOL finished) {        
}];

UICollectionViewCell の高さを変更し、同時に UICollectionViewCell のサブビューを再編成します。

4

4 に答える 4

1

必要なアニメーションで -[UIView animateWithDuration:animations:] ブロックにラップするだけです。おそらく正しい方法ではありませんが、iOS 8 では問題なく動作するようです。

于 2015-04-09T23:09:39.117 に答える
0

いいえ、performBatchUpdates によるアニメーションのタイミングをカスタマイズする方法はありません。コレクションビューで、特に Cell だけをアニメーション化しようとしているようです。+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations を代わりに使用しないのはなぜですか?

于 2013-08-09T23:04:02.277 に答える