2

NSTimer セレクター内に次のコードを取得しました。

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:0];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:1];
[UIView commitAnimations];

そこで、UILabel (infoLbl) に単純なフェードイン/フェードアウト ループを実装したいと考えています。

さて、このコードでは、UILabel が突然消えてからフェードインするため、フェードイン ステップのみを取得します。

いくつかの提案?

ありがとう。

4

2 に答える 2

10
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:0];
[UIView commitAnimations];

//This delegate is called after the completion of Animation.
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:2.0];
  [infoLbl setAlpha:1];
  [UIView commitAnimations];

}

これの挿入図、NStimer Selecorを使用している場合は、uilabelテキストの色を変更してみませんか?お気に入り:

-(void)timerSelector
{
    if([textLabel textColor] == [UIColor blackColor])
    {
        [textLabel setTextColor:[UIColor grayColor]];   
    }
    else
    {
        [textLabel setTextColor:[UIColor blackColor]];  
    }
}

上記の方法を使用すると、ループ内で非常に簡単にフェードイン/フェードアウトできます。

于 2010-04-07T10:04:59.843 に答える
0

最初にフェードインしanimationDidStopSelector:、セレクター内に and を設定して (詳細についてはドキュメントを参照)、フェードアウトするように指示します。

于 2010-04-07T09:49:58.653 に答える