I have a label that appears after a gesture and I want to fade the label out. The following code works, but if I do several gestures in a row, the last ones don't finish the fade and display but then stop abruptly. Here is my code:
- (void) gestureLabelAppear:(NSString *)theLabelText
{
myLabel = [[UILabel alloc] initWithFrame:CGRectMake(gestureEndPoint.x, gestureEndPoint.y, 200, 20)];
myLabel.center=CGPointMake(gestureEndPoint.x, gestureEndPoint.y);
myLabel.textAlignment = UITextAlignmentCenter;
myLabel.text =theLabelText;
[self.view addSubview:myLabel];
[self fadeOutLabels];
}
-(void)fadeOutLabels
{
[UIView animateWithDuration:3.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
myLabel.alpha = 0.0;
}
completion:^(BOOL finished) {
[myLabel removeFromSuperview];
NSLog(@"removed label");
}];
}
Any suggestions on how to fix?