Iphone 我想用动画将imageview放置在不同的位置
我正在尝试在不同的位置设置多个图像这是我的代码任何人都可以帮助我在不同的位置设置imageviewIphone 我想用动画将imageview放置在不同的位置,iphone,objective-c,Iphone,Objective C,我正在尝试在不同的位置设置多个图像这是我的代码任何人都可以帮助我在不同的位置设置imageview - (void)viewDidLoad { [super viewDidLoad]; frameX = 45.0f; frameY = 60.0f; imagearr = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"King2.png"], [UIIma
- (void)viewDidLoad
{
[super viewDidLoad];
frameX = 45.0f;
frameY = 60.0f;
imagearr = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"King2.png"],
[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"queen.png"],
[UIImage imageNamed:@"King.png"],nil];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
CGFloat dx = self.view.frame.size.width/2;
CGFloat dy = self.view.frame.size.height/2;
[cards setAnimationImages:imagearr];
CGRect frame = cards.frame;
frame.size.width = frameX;
frame.size.height = frameY;
[cards setFrame:frame];
cards.animationRepeatCount = 1;
for (int i=0; i<5;i++)
{
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
switch (i)
{
- (void)viewDidLoad
{
[super viewDidLoad];
frameX = 45.0f;
frameY = 60.0f;
imagearr = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"King2.png"],
[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"queen.png"],
[UIImage imageNamed:@"King.png"],nil];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
CGFloat dx = self.view.frame.size.width/2;
CGFloat dy = self.view.frame.size.height/2;
[cards setAnimationImages:imagearr];
CGRect frame = cards.frame;
frame.size.width = frameX;
frame.size.height = frameY;
[cards setFrame:frame];
cards.animationRepeatCount = 1;
for (int i=0; i<5;i++)
{
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
switch (i)
{
case 0:
[cards setCenter:CGPointMake(dx, dy-120.0)];
cards.transform = CGAffineTransformMakeRotation(0);
break;
default:
break;
}
[self.view addSubview:cards];
[UIView commitAnimations];
}
default:
break;
}
[self.view addSubview:cards];
[UIView commitAnimations];
}
-(void)viewDidLoad
{
[超级视图下载];
frameX=45.0f;
frameY=60.0f;
imagearr=[[NSArray alloc]initWithObjects:[UIImage ImageName:@“King2.png”],
[UIImage ImageName:@“3.png”],[UIImage ImageName:@“queen.png”],
[UIImage ImageName:@“King.png”],无];
}
-(iAction)hidebtn:(id)发送方
{
[btn setHidden:真];
[自动设置卡];
}
-(无效)设置卡
{
CGFloat dx=self.view.frame.size.width/2;
cgdy=self.view.frame.size.height/2;
[卡片设置动画图像:imagearr];
CGRect frame=cards.frame;
frame.size.width=frameX;
frame.size.height=frameY;
[卡设置帧:帧];
cards.animationRepeatCount=1;
对于(int i=0;i您添加子视图太晚了,您无法为屏幕上没有的内容设置动画。在开始在某个位置设置动画之前添加子视图,然后将其设置为目标位置。再提供一点信息就好了,您到底想做什么?我有一个包含多个图像的数组,我想在不同位置绘制每个图像,就像在纸牌游戏中,我们将纸牌分发给每个玩家。所以我想在不同的地方画多张纸牌。你能告诉我们纸牌的类型吗?简单的纸牌,比如我们玩Solister或poker,等等,卡片是UIImageview,btn是Roundrect butoon,两者都与其定义的变量相连,所有过程都顺利完成,但都在imageview的末尾(卡片)现在看到了,没有正确制作动画。谢谢你的回复
- (void)viewDidLoad
{
[super viewDidLoad];
frameX = 45.0f;
frameY = 60.0f;
imagearr = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"King2.png"],
[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"queen.png"],
[UIImage imageNamed:@"King.png"],nil];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
CGFloat dx = self.view.frame.size.width/2;
CGFloat dy = self.view.frame.size.height/2;
[cards setAnimationImages:imagearr];
CGRect frame = cards.frame;
frame.size.width = frameX;
frame.size.height = frameY;
[cards setFrame:frame];
cards.animationRepeatCount = 1;
for (int i=0; i<5;i++)
{
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
switch (i)
{
- (void)viewDidLoad
{
[super viewDidLoad];
frameX = 45.0f;
frameY = 60.0f;
imagearr = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"King2.png"],
[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"queen.png"],
[UIImage imageNamed:@"King.png"],nil];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
CGFloat dx = self.view.frame.size.width/2;
CGFloat dy = self.view.frame.size.height/2;
[cards setAnimationImages:imagearr];
CGRect frame = cards.frame;
frame.size.width = frameX;
frame.size.height = frameY;
[cards setFrame:frame];
cards.animationRepeatCount = 1;
for (int i=0; i<5;i++)
{
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
switch (i)
{
case 0:
[cards setCenter:CGPointMake(dx, dy-120.0)];
cards.transform = CGAffineTransformMakeRotation(0);
break;
default:
break;
}
[self.view addSubview:cards];
[UIView commitAnimations];
}
default:
break;
}
[self.view addSubview:cards];
[UIView commitAnimations];
}