2012-03-17 6 views
0

アニメーションの長さは1から制限(可変)までのアニメーションのアニメーションを1.5秒にしたい。私はこのアニメーションが動作するはずメソッドを呼び出すたびに((例えば、0から増分をアニメーション化:70) int型J = 1;how to do xcodeのアニメーションのインクリメント

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration: 1.5]; 
[UIView setAnimationDelegate: self]; 

do{ 
self.label.text=[NSString stringWithFormat:@"%ï", j]; 
} 

while(j<=limit); 

[UIView commitAnimations]; 

番号のインクリメントをアニメーション化する助けてください.....。

答えて

3

あなたはこのような何かを行うことはできませんあなたが唯一のビューのanimatable propertiesをアニメーション化することができ、これらは次のとおりです。。。frameboundscentertransformalphabackgroundColorcontentStretch

あなたがしたいです1.53秒ごとにラベルを更新するNSTimerを使用してください。

おそらく、これらの線に沿って何か:その後、

- (void)startAnimationWithLimit:(NSInteger)limit { 
    self.limit = limit; 
    self.timerFireCount = 0; 
    [self.timer invalidate];  // stop timer if one is running already 
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(timerFired:) userInfo:nil repeats:YES]; 
} 

- (void)timerFired:(NSTimer *)timer { 
    self.timerFireCount++; 
    self.label.text = [NSString stringWithFormat:@"%i", self.timerFireCount]; 
    if (self.timerFireCount > self.limit) { 
     [timer invalidate]; 
     self.timer = nil; 
     self.label.text = @"Press start"; 
    } 
} 

[self startAnimationWithLimit:70];

+0

でタイマーをスタートは答えmuch..forようお願いします。実際に私はxcodeを初めて使う – faris