2013-02-04 33 views
0

可能重複:
Blinking effect on UILabel如何使一個UILabel閃爍在iPhone

如何使iPhone一個UILabel閃爍。我也嘗試過使用Google搜索。但是,這些問題是動畫標籤改變顏色。但我不需要改變顏色。我真的需要UILabel眨眼。可能嗎?

+2

您可以對其al pha而不是它的顏色。 – shadowhorst

+0

添加一個切換隱藏屬性的NSTimer對象。 – OneGuyInDc

+0

@OneGuyInDc代碼片段會有幫助...是一個初學者。 – 2vision2

回答

7

下面的代碼片段:

在你的控制器創建的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)]; 
} 

玩得開心

+0

謝謝你:) –

1

1:在你的類

NSTimer *updateTimer 

2創建的NSTimer對象:實例計時器 -

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 
} 
+0

看起來像以前的帖子打敗了我 – OneGuyInDc