gpt4 book ai didi

ios - UICollectionViewCell performBatchUpdates 动画时间

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:03:10 38 4
gpt4 key购买 nike

有一种方法可以自定义通过 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/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com