10

以下是我水平滚动 UILabel 使其显示为选框效果的代码。但是动画从中心的标签开始并滚动到它的宽度,然后再次从中心开始统计。我想要从左到右像选框一样连续滚动。任何人都可以帮助我。

-(void)loadLabel{

    if (messageView) {
        [messageView removeFromSuperview];
    }

    NSString *theMessage = text;
    messageSize = [theMessage sizeWithFont:font];
    messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, messageSize.width, 916)]; //x,y,width,height
    [messageView setClipsToBounds:NO]; // With This you prevent the animation to be drawn outside the bounds.
    [self.view addSubview:messageView];
    lblTime = [[RRSGlowLabel alloc] initWithFrame:CGRectMake(0, 0, messageSize.width, 916)]; //x,y,width,height
    [lblTime setBackgroundColor:[UIColor yellowColor]];
    lblTime.font = font;
    [lblTime setText:theMessage];
    lblTime.glowOffset = CGSizeMake(0.0, 0.0);
    lblTime.glowAmount = 90.0;
    lblTime.glowColor = color;
    [lblTime setClipsToBounds:NO];
    [lblTime setTextColor:color];
    [lblTime setTextAlignment:UITextAlignmentLeft];
    lblTime.frame = messageView.bounds ; //x,y,width,height
    [messageView addSubview:lblTime];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:speed];

    [UIView setAnimationRepeatCount:HUGE_VALF];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:messageView cache:YES];
    lblTime.frame = CGRectMake(-messageSize.width, 45, messageSize.width, 916); //x,y,width,height
    [UIView commitAnimations];
}
4

0 回答 0