如何通过翻转和缩放实现iPhone视图过渡动画? [英] how to implement an iPhone view transition animation with both flipping and scaling?

查看:251
本文介绍了如何通过翻转和缩放实现iPhone视图过渡动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实现我们在iPhone音乐应用程序的封面屏幕中看到的动画?当您点击一个小视图时,它会翻转并缩放到另一个视图?我怎样才能做到这一点?我可以使用核心动画来翻转和缩放视图,但是如何转换到另一个视图呢?谢谢

how can I implement the animation we see in the iPhone Music app's coverflow screen? when you click on a small view, it flips and scales up to another view? how can I do this? I can use core animation to flip and scale a view, but how can I do the transition to another view? thanks

推荐答案

你需要一个 UIView 作为两个<$的容器c $ c> UIView s(frontside / backside),然后在执行以下动画时从子容器中删除/添加这些/作为子视图:

You need an UIView as Container for the two UIViews (frontside/backside) and then remove/add these from/to the container as subviews while doing the animations in between:

UIView *flipContainer;
UIView *frontSide;
UIView *backSide;
  //...
-(void)turnUp
{
  [backSide removeFromSuperview];
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:1.0];
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:flipContainer cache:YES];
  [UIView setAnimationDuration:1.0];
  CGAffineTransform transform = CGAffineTransformMakeScale(1.2, 1.2);
  flipContainer.transform = transform;
  [UIView commitAnimations];
  [flipContainer addSubview:frontSide];
}
-(void)turnDown
{
  [frontSide removeFromSuperview];
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:1.0];
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:flipContainer cache:YES];
  [UIView setAnimationDuration:1.0];
  CGAffineTransform transform = CGAffineTransformMakeScale(1, 1);
  flipContainer.transform = transform;
  [UIView commitAnimations];
  [flipContainer addSubview:backSide];
}

这篇关于如何通过翻转和缩放实现iPhone视图过渡动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆