1
我想在不同的位置設置多個圖像這是我的代碼任何人都可以幫助我在不同的位置設置imageview。我想將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];
}
多一點信息會很好,你到底想做什麼? – Robin 2011-04-23 08:42:10
我有一個數組與多個圖像,我想繪製每個圖像在不同的位置,就像我們爲卡片遊戲中的每個玩家分發卡片一樣。所以我想在不同的地方繪製多張卡片圖像。 – Anjan 2011-04-23 08:44:59
你能告訴我們什麼類型的卡? – 2011-04-23 08:48:43