我有一个手势后出现的标签,我想淡出标签。下面的代码有效,但如果我连续做几个手势,最后一个不会完成淡入淡出和显示,而是突然停止。这是我的代码:
- (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");
}];
}
有关如何修复的任何建议?