如何翻转UIImageView? [英] How can I flip a UIImageView?
本文介绍了如何翻转UIImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何翻转UIImageView?
How can I flip an UIImageView?
推荐答案
创建两个UIImageView frontImageView& backImageView
create two UIImageView frontImageView & backImageView
创建一个UIView containerView以包含UIImageView
create one UIView containerView to contain UIImageView
在开头显示frontImageView。
Show frontImageView in the beginning.
翻转后,显示backImageView
after flip, show backImageView
代码:
// before flip
frontImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"test.png"]];
containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = CGPointMake(200,200);
[self.view addSubview:containerView];
[containerView addSubview:frontImageView];
-(IBAction)flipButtonClicked:(id)sender
{
backImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"cardback.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:containerView
cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];
}
这篇关于如何翻转UIImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文