我写了下面的代码,用于在标签上添加选取框效果,并在视图上逐一显示标签。UILabels Marquee +在动画标签上重叠
- (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];
}
}];
}
一些如何,在阵列的字符串被显示以这样的方式,在执行动画,它们是重叠的。
任何想法,任何人?
让我知道,以防需要更多信息。
您的标签是否将文本更新为位于nextIndex的数组中的字符串?什么marqueeMessage:strMessage呢? –
我发布的代码本身就是函数'marqueeMessage:strMessage' ...让我再次编辑帖子... – viral
@PratyushaTerli:是的,标签正在更新。但是它们彼此重叠。 – viral