有一种方法可以自定义通过 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 的 subview 。
最佳答案
UICollectionView 的批量更新有一种方法可以自定义持续时间和Timing 函数。试试下面的代码。这是它的样子https://youtu.be/R0VdC4dliPI
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[CATransaction begin];
[CATransaction setAnimationDuration:0.3];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0 :1.8 :0 :1]];
[self.menuCollectionView performBatchUpdates:^{
[self.menuCollectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];
[animatableMenuItems insertObject:@"" atIndex:index];
} completion:^(BOOL finished) {
}];
[CATransaction commit];
[UIView commitAnimations];
在 https://github.com/DoddaSrinivasan/MultiRowUITabBar 找到示例的完整源代码
关于ios - UICollectionViewCell performBatchUpdates 动画时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16836583/