我尝试实现动画: 当您进入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 Gallery动画最相似的动画,但不使用OpenGL吗?
答案 0 :(得分: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)
答案 1 :(得分:4)
我知道它有点晚了。但是,您应该检查Ciechan的名为BCGenieEffect的解决方案。可以找到here。它纯粹的核心动画,非常容易理解。我认为这就是你要找的东西。
祝你好运答案 2 :(得分:3)
此时,您正在谈论的确切动画无法使用Core Animation或UIKit完成。您需要使用OpenGL并将图像应用为纹理并在那里进行动画。
答案 3 :(得分: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 commitAnimations];
或在网上搜索名为“suckEffect”的核心图像转换