【发布时间】:2021-11-30 20:08:44
【问题描述】:
如何在选择时为 UICollectionViewCell 的内容展开动画?
目前我在我的 didSelectItemAtIndexPath 上使用过渡动画来为视图设置动画,这不像 AppStore 卡片动画那样流畅。
这是我当前的代码...
AnimateStaticImageViewController *animateImageVC = [[AnimateStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.3);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformIdentity;
}];
}];
}];
[self presentViewController:animateImageVC animated:NO completion:nil];
【问题讨论】:
-
collectionViewLayout上有一个api...让我看看我是否可以绞尽脑汁找到它。我认为它会做你想做的事。
-
是AnimatedCollectionViewLayout 吗?我需要写在目标 c 上的东西。谢谢!
-
不,这是我自己的代码而不是框架。我只是在使用 UICollectionViewLayout。我想我可能对此有疑问。还在寻找:D
-
给你……我想这就是你要问的……虽然这个问题有点含糊。但听起来您想在为集合视图的布局设置动画的同时为单元格的内容设置动画。 stackoverflow.com/questions/51236002/… 请注意...该问题和答案是用 Swift 编写的,但是(除了轻微的语法更改)一切都应该直接在 Objective-C 中运行。它只是使用香草 UICollectionView。
-
我刚刚用另一个第三方库here 解决了这个问题。顺便说一句,谢谢@Fogmeister!
标签: ios objective-c uicollectionviewcell uianimation