我想用动画改变imageview的位置。它就像绘制扑克牌一样,它会设置为帮助我这里的任何人。
代码 - :
@interface PockerAppViewController : UIViewController
{
UIButton *btn;
UIImageView *cards;
}
@property(nonatomic,retain) IBOutlet UIButton *btn;
@property(nonatomic,retain) IBOutlet UIImageView *cards;
-(IBAction)hidebtn:(id)sender;
-(void)setCards;
@end
--------------------------------。M文件------------- ----------------
@implementation PockerAppViewController
@synthesize btn,cards;
/ * //指定的初始化程序。覆盖以执行加载视图之前所需的设置。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization
}
return self;
}
//在加载视图后实现viewDidLoad以进行其他设置,通常是从笔尖。
- (void)viewDidLoad
{
[super viewDidLoad];
cards = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"King.png"]];
//[cards setHidden:TRUE];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
[cards setFrame:cards.frame];
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
[cards setCenter:CGPointMake(60,240)];
[UIView commitAnimations];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint pos = [touch locationInView:touch.view];
NSLog(@"X: %f",pos.x);
NSLog(@"X: %f",pos.y)
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
这是我的数据,它帮助我解决了这个问题..
答案 0 :(得分:1)
尝试这样的事情:
[URImageView setFrame:CurrentPositionFrame];
[UIView beginAnimations:@“animateTableView”context:nil];
[UIView setAnimationDuration:0.4];
[URImageView setFrame:ToTheNewPositionFrame];
[UIView commitAnimations];
<小时/> 当直到指出您还可以使用中心属性:
[UIView beginAnimations:@“animateTableView”context:nil];
[UIView setAnimationDuration:0.4];
[URImageView setCenter:CGPointMake(nPositionX,nPositionY)];
[UIView commitAnimations];
谢谢直到。
答案 1 :(得分:0)