2012-07-06 20 views
6

पर एनीमेशन फीका है मेरे पास एक लेबल है जिसे मैं फीका करना चाहता हूं और फिर फीका करना चाहता हूं।फीका हुआ, यूलाबेल

-(void) fadein 
{ 
    scoreLabel.alpha = 0; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
    [UIView setAnimationDuration:2]; 
    scoreLabel.alpha = 1; 
    [UIView commitAnimations]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
} 



-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:2]; 
scoreLabel.alpha = 0; 
[UIView commitAnimations]; 
} 
इस कोड मैं इस स्थिति पाने से

: यहाँ मेरी कोड है मेरी लेबल में फीका और फिर मैं fadeout एनीमेशन नहीं दिख रहा है। मैं इसे कैसे ठीक कर सकता हूं?

उत्तर

11
-(void) fadein 
{ 
    scoreLabel.alpha = 0; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 

    //don't forget to add delegate..... 
    [UIView setAnimationDelegate:self]; 

    [UIView setAnimationDuration:2]; 
    scoreLabel.alpha = 1; 

    //also call this before commit animations...... 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
    [UIView commitAnimations]; 
} 



-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
{ 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:2]; 
    scoreLabel.alpha = 0; 
    [UIView commitAnimations]; 
} 
+0

धन्यवाद! मैं setAnimationDelagate का उपयोग करना भूल गया, अब यह पूरी तरह से काम करता है! – user1492776

+0

आपका स्वागत है .. अगर यह काम करता है तो उत्तर दें और जवाब स्वीकार करें :) – mayuur

2

setAnimationDidStopSelector को कॉल करने से पहले एनिमेशन प्रतिबद्ध किया जाना चाहिए:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
[UIView setAnimationDuration:2]; 
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 

scoreLabel.alpha = 1; 

[UIView commitAnimations]; 
संबंधित मुद्दे