动画,例如从 iPhone 照片库中删除时



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

[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图库动画的动画,但不使用OpenGL?

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

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)

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

祝你好运

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

我想你说的是"吸"过渡动画。

可以

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

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

[UIView beginAnimations:nil context:NULL]; [UIView set动画持续时间:1.0]; [UIView setAnimationTransition: transtionIndex forView:containerView cache:NO]; [容器视图添加子视图:新视图]; [旧视图从超级视图中删除]; [UIView commitAnimations];

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

最新更新