2013-07-21 103 views
0

我有81个按钮。我想要做的是每个按钮都必须离开屏幕,而不是非屏幕按钮,它们必须回来。循环中按钮的动画ios

例如:

1. 

*** 
*** 
*** 

2. 
** 
*** 
*** 

3. 
    * 
*** 
*** 

等一个

比他们必须回来:

1. 


    * 

2. 


** 

3. 


*** 

等一个

我[UIView的animateWithDuration]中环试但它一起动画,不分割:

for(int i = 0 ; i < 9 ; i ++) 
for(int j = 0 ; j < 9 ; j ++){ 
    [uiview animateWithDuration:0.5f animations:^{ 
    button.center = CGPointMake(self.view.frame.size.width, self.view.frame.size.height); 
    } 
} 
+0

所有动画在一起,不拆 – poppytop

回答

0

我周围有点

-(void)move1:(NSArray *)array index:(int)index { 
UIButton *btn = array[index]; 
[UIView animateWithDuration:.5 animations:^{ 
    btn.frame = CGRectMake(0, 0, btn.frame.size.width, btn.frame.size.height); 
} completion:^(BOOL finished) { 
    if ([array count] != index+1) [self move1:array index:index+1]; 
}]; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    NSArray *buttonArray = [[NSArray alloc] initWithObjects:b1,b2,b3,b4,b5, nil]; 

    [self move1:buttonArray index:0]; 
} 
+0

这应该是你寻找的东西。 – Arbitur

+0

谢谢。它帮助了很多! – poppytop

0

据我所知,你想要一次移动每个按钮。在UIView中添加每个UIButton,然后将该UIView移出屏幕。

否则在NSArray中添加的每个按钮,并使用一个for循环将它们都移动这样的:

for (UIButton *btn in buttonArray) { 
    btn.frame = [CGRectMake(width, height, x, y)]; 
} 
+0

没有ü错过理解我。我想动画每个按钮的个体 – poppytop

+0

这就是for循环所做的 – Arbitur

+0

我知道这一点,我试过它,但动画拉我的所有按钮一次。就像我在上面的代码中所写的 – poppytop

-1
 AddEventListener(Event.ENTER_FRAME, update);// function to show the bottons back again 
    function update(e:Event){ 
    //manipulate te propety to move sidewards 
    x = x - speed; // move to the left 
    // aceleration 
    speed = speed + 0,1; 
    // limit the positino to stay on the screen 
    if (x < -width) { // meanes off the left of the screen 
    X = stage.stageWidth + width; 
    }} 

添加的代码打在movieClip或者botton里面。下面到现场。

 AddEventListener(Event.ENTER_FRAME, mainloop); 

     function mainloop(e:Event){ 
     for (var i = 0; i<nunChildren; i++){ 
     } 
+0

使用此代码,您可以为任何一个单独的动画制作动画。有兴趣随意的位置? – Victor

+0

http://www.youtube.com/watch?v=eIgyHAmfJIM < - 这将帮助您解决您的问题。 – Victor

+0

我会试试这个;) – poppytop