0

重複の可能性:
UILabel の点滅効果

UILabeliPhoneでまばたきをする方法。私はグーグルとSOでも試しました。しかし、これらの質問は、ラベルをアニメーション化して色を変更することです。しかし、私は色を変える必要はありません。UILabel を点滅させる必要があります。出来ますか?

4

2 に答える 2

8

コードスニペットは次のとおりです。

コントローラでNSTimerプロパティを作成します。

@property (strong, nonatomic) NSTimer *timer;

viewDidLoadメソッドで、タイマーを開始します。

self.timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(toggleLabelAlpha) userInfo:nil repeats:YES];

最後に、ラベルを切り替える関数を記述します

- (void)toggleLabelAlpha {

    [self.label setHidden:(!self.label.hidden)];
}

楽しむ

于 2013-02-04T15:14:21.997 に答える
1

1:クラスにNSTimerオブジェクトを作成します

NSTimer *updateTimer

2:タイマーをインスタンス化します-

updateTimer = [NSTimer scheduledTimerWithTimeInterval:1000 
                                               target:self 
                                               selector:@selector(appUpdate:)
                                               userInfo:nil
                                               repeats:YES];

3:タイマーが使用するセレクター(メソッド)を記述します-

- (void)appUpdate:(NSTimer*)theTimer
{
    //Toggle the Text between a empty string and the text you want to display here
}
于 2013-02-04T16:08:31.757 に答える