I am trying to fade into the UIView that I created by animating alpha. I need to fade it, leave it visible for a few seconds, and then disappear.
The damping function works fine. The view gradually disappears. But attenuation simply makes the gaze appear instantly, rather than slowly appearing after an interval of 0.5 seconds.
So it seems that fading in the animation does not work, just setting alpha to 1.0 . I am here somehow perplexed. Any ideas what I'm doing wrong? Thanks!
-(void)presentPopupPhrase:(NSString *)phrase inView:(UIView *)view withDelegate:(id)delegate andCompletion:(void (^)(BOOL completed))completion { MessagePopupView *pv = [[[MessagePopupView alloc] initWithFrame:self.frame andText:phrase] autorelease]; pv.alpha = 0.0; [view addSubview:pv]; [self fadeInMPV:pv withDuration:self.fadeDuration andDelay:self.fadeInDelay]; [self fadeOutMPV:pv withDuration:self.fadeDuration afterDelay:self.fadeOutDelay withCompletion:completion andDelegate:delegate]; } -(void)fadeInMPV:(MessagePopupView *)mpv withDuration:(NSTimeInterval)duration andDelay:(NSTimeInterval)delay { [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveLinear animations:^{ mpv.alpha = 1.0; } completion:nil]; } -(void)fadeOutMPV:(MessagePopupView *)mpv withDuration:(NSTimeInterval)duration afterDelay:(NSTimeInterval)delay withCompletion:(void (^)(BOOL completed))completion andDelegate:(id)delegate { [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveLinear animations:^{ mpv.alpha = 0.0; } completion:completion]; }
EDIT:
If this helps, here is the VC code where I call it:
-(void)viewDidAppear:(BOOL)animated { CGRect phraseFrame = CGRectMake(20, 341, 280, 65); PopupPhraseController *phraseController = [[[PopupPhraseController alloc] initWithFrame:phraseFrame] autorelease]; [phraseController presentPopupPhrase:@"Test Phrase" inView:self.view withDelegate:self andCompletion:^(BOOL completed){ if (completed) { NSLog(@"completed"); } else { NSLog(@"not completed"); } NSLog(@"blocked!"); }]; [super viewDidAppear:animated]; }
source share