2016-04-18 14 views
1

CAAnimationを使用してこれを実現するために、3つの異なるビューを順番にアニメーション化しようとしています。 Gcdを使って、最初のサークルを表示していて、他のサークルを隠している3つのメソッドを1つずつ呼び出すことを試みました。しかし、いくつかの問題に直面しました。3つのビューを1つずつアニメ化

enter image description here

答えて

1

あなたは、アニメーションを使用せずに、このような何かを行うことができます。あなたの3つのエクサ1,2のためのビューと3

NSTimer *timerLabelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimerLabel) userInfo:nil repeats:YES]; 


int counter = 0; 
-(void)updateTimerLabel{ 



if (counter == 0) { 

    UIView *tempView = [self.view viewWithTag:0]; 
    tempView.backgroundColor = [UIColor whiteColor]; 

    UIView *tempView1 = [self.view viewWithTag:1]; 
    tempView.backgroundColor = [UIColor blackColor]; 

    UIView *tempView2 = [self.view viewWithTag:2]; 
    tempView.backgroundColor = [UIColor blackColor]; 

} 
if (counter == 1) { 

    UIView *tempView = [self.view viewWithTag:0]; 
    tempView.backgroundColor = [UIColor blackColor]; 

    UIView *tempView1 = [self.view viewWithTag:1]; 
    tempView.backgroundColor = [UIColor whiteColor]; 

    UIView *tempView2 = [self.view viewWithTag:2]; 
    tempView.backgroundColor = [UIColor blackColor]; 

} 

if (counter == 2) { 

    UIView *tempView = [self.view viewWithTag:0]; 
    tempView.backgroundColor = [UIColor blackColor]; 

    UIView *tempView1 = [self.view viewWithTag:1]; 
    tempView.backgroundColor = [UIColor blackColor]; 

    UIView *tempView2 = [self.view viewWithTag:2]; 
    tempView.backgroundColor = [UIColor whiteColor]; 

    //removed counter = 0; from here 
} 

//Update 
counter ++; 

if (counter == 3) { 
    counter =0; 
} 


} 

から
設定タグホープこれは:)

+0

NSTimerブロックUIを使用します。その他の方法で ? – sujay

+0

更新部分を確認してください。これはカウンター増分では少し間違いでした。このようにしてみてください。私のデモではうまく動作します。 :) – Lion

0

私はUIImageView.animationImagesを使用することをお勧めするのに役立ちます、それはアニメーションよりもはるかに簡単かつ迅速に、より少ないエネルギー消費です。

関連する問題