我编写了以下代码,用于在视图上一一显示的标签上添加选取框效果。
- (void)marqueeMessage:(NSString *)messageString
{
UILabel *label = [[UILabel alloc] initWithFrame:(CGRectMake(520, 0, 480, 21))];
label.text = messageString;
[self.view addSubview:label];
[UIView animateWithDuration:0.2
                 animations:^ {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:20];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
    label.frame = CGRectMake(-480, 0, 480, 21);
    [UIView commitAnimations];
}
                 completion:^(BOOL finished) {
    NSLog(@"Animation Done!");
    if (array.count > 0)
    {
        nextIndex++;
        NSString *strMessage = [array objectAtIndex:nextIndex];
        [self marqueeMessage:strMessage];
    }
}];
}
不知何故,数组中的字符串以这样的方式显示,即它们在执行动画时重叠。
任何想法,任何人???
让我知道,以防需要更多信息。