[英]animate UIImageView with flip animation
我是Objective-c和cocoa中的菜鸟,我想用翻转动画实现UIImageView的简单动画。 但我很难做到这一点。 以下是我的片段:
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];
谢谢。
您引用一个名为view
的对象,该对象从未声明。 我认为你需要改变你的倒数第二行
[containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
看看是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.