[英]animate UIImageView with flip animation
I'm a noob in objective-c and cocoa, and I would like to implement a simple animation of UIImageView with flipping animation. 我是Objective-c和cocoa中的菜鸟,我想用翻转动画实现UIImageView的简单动画。 But I'm having a hard time doing it.
但我很难做到这一点。 Below are my snippets:
以下是我的片段:
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,33,33)];
UIImageView *img1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG1]];
UIImageView *img2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG2]];
[containerView addSubview:img1];
[containerView addSubview:img2];
[self.view addSubview:containerView];
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
Thanks. 谢谢。
You refer to an object called view
which is never declared. 您引用一个名为
view
的对象,该对象从未声明。 I think you need to change your second-to-last line to 我认为你需要改变你的倒数第二行
[containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
See if that helps. 看看是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.