如何在选择时动画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];
所以,我在点击图像后立即在我的应用程序的主页staticImageCollectionView中尝试模态过渡动画。核心动画&transform机制不适合我,因为我需要AppStore的纸牌动画。使用这个库工作了一些麻烦!以下这个…
-
按以下步骤设置库。
-
调用transitioningDelegate didSelectItemAtIndexPath animationViewController的(或prepareForSegue如果处理segue-navigation控制器)。
-
在完成块中调用它以忽略闪烁的&视图显示延迟问题。
AnimatedStaticImageViewController *animateImageVC = [[AnimatedStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.2
animations:^{
animateImageVC.transitioningDelegate = self;
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self presentViewController:animateImageVC animated:YES completion:nil];
}];
设置imageView时要小心,imageView是动画的主要呈现方式。
确保你声明了委托'RMPZoomTransitionAnimating' &'RMPZoomTransitionDelegate'方法在fromViewController和toViewController上。