5

我尝试实现动画:当你进入 iPhone Gallery 时,按下图像,你会看到全屏图像。您可以在下面看到带有垃圾按钮的工具栏。当您按下此按钮时,图像被动画删除。我尝试实现这个,但我不知道如何实现图像的变换,苹果使用。这是最好的,我可以这样做:

[UIView transitionWithView:self.view duration:0.1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
        [self.view addSubview:scrollImageView];
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
            CGRect frame = scrollImageView.frame;
            frame.size = CGSizeMake(frame.size.width * 0.75, frame.size.height * 0.75);
            frame.origin = CGPointMake((size.width - frame.size.width) / 2, (size.height - frame.size.height) / 2);
            scrollImageView.frame = frame;
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
                CGRect frame = scrollImageView.frame;
                frame.size = CGSizeMake(frame.size.width * 0.05, frame.size.height * 0.05);
                frame.origin = CGPointMake(size.width, size.height);
                scrollImageView.frame = frame;
                CGAffineTransform transform = scrollImageView.transform;
                CGAffineTransform rotatedTransform = CGAffineTransformRotate(transform, 45 * 3.14 / 180);
                scrollImageView.transform = rotatedTransform;
            } completion:^(BOOL finished) {
                [scrollImageView removeFromSuperview];
            }];
        }];
    }];

先感谢您。

更新 据我所知,我无法使用 Core-Animation 制作此动画,但有人可以建议我制作与 iPhone Gallery 动画最相似的动画,但不使用 OpenGL?

4

4 回答 4

6

您可以为此动画使用以下示例:

UIView *senderView = (UIView*)sender;

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
            anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            anim.duration = 0.125;
            anim.repeatCount = 1;
            anim.autoreverses = YES;
            anim.removedOnCompletion = YES;
            anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)];
            //[senderView.layer addAnimation:anim forKey:nil];


UIBezierPath *movePath = [UIBezierPath bezierPath];
            [movePath moveToPoint:icon.center];
            [movePath addQuadCurveToPoint:senderView.center
                             controlPoint:CGPointMake(senderView.center.x, icon.center.y)];

            CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
            moveAnim.path = movePath.CGPath;
            moveAnim.removedOnCompletion = YES;

            CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
            scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
            scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
            scaleAnim.removedOnCompletion = YES;

            CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
            opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
            opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
            opacityAnim.removedOnCompletion = YES;

            CAAnimationGroup *animGroup = [CAAnimationGroup animation];
            animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim, opacityAnim, nil];
            animGroup.duration = 0.5;
            [icon.layer addAnimation:animGroup forKey:nil];

我已经修改了代码,你必须在其中进行以下更改,将发送者视图设置为self.view,并根据您的要求更改动画的结束点(当前为senderView.center)

于 2012-06-21T12:41:35.897 回答
4

我知道有点晚了。但是,您应该检查 Ciechan 的名为BCGenieEffect的解决方案。可以在这里找到。它的纯核心动画非常容易理解。我想这就是你要找的。

祝你好运

于 2013-03-28T22:07:56.270 回答
3

此时,您所谈论的确切动画无法使用 Core Animation 或 UIKit 完成。您需要使用 OpenGL 并将图像作为纹理应用并在其中制作动画。

于 2012-06-21T11:07:18.410 回答
0

我认为您在谈论“吸”过渡动画。

可以触发它,但它是一个私人过渡,如果你使用它,Apple 可能会拒绝你的应用程序。

此代码应该使用 103 的转换代码来执行此操作:

[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:transtionIndex forView:containerView cache:NO]; [containerView addSubview: newView]; [oldView removeFromSuperview]; [UIView 提交动画];

或者在网上搜索一个名为“suckEffect”的核心图像过渡

于 2012-06-22T03:41:54.350 回答