如何移动标签?
我想显示一个歌曲标题,从右侧移动到左侧,持续时间我可以设置。正如您在汽车 radio 上看到的那样。当标签离开屏幕时,它应该从右侧重新出现
谢谢你
最佳答案
Iphone 不为 UILabel 提供此类功能,您需要为此设置动画标签。
引用这个链接
https://github.com/cbpowell/MarqueeLabel
只需拖放 MarqueeLabel.h 和 MarqueeLabel.m 文件并创建标签,如下所示:
MarqueeLabel *rightLeftLabel = [[MarqueeLabel alloc] initWithFrame:CGRectMake(10, 260, self.view.frame.size.width-20, 20) rate:50.0f andFadeLength:10.0f];
rightLeftLabel.numberOfLines = 1;
rightLeftLabel.shadowOffset = CGSizeMake(0.0, -1.0);
rightLeftLabel.textAlignment = NSTextAlignmentRight;
rightLeftLabel.textColor = [UIColor colorWithRed:0.234 green:0.234 blue:0.234 alpha:1.000];
rightLeftLabel.backgroundColor = [UIColor clearColor];
rightLeftLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.000];
rightLeftLabel.marqueeType = MLRightLeft;
rightLeftLabel.text = @"This text is not as long, but still long enough to scroll, and scrolls the same speed but to the right first!";
[self.view addSubview:rightLeftLabel];
他们创建了 UIView 子类和动画 UILabels,它们是 UIView 的 subview 。
希望这可以帮助你:)
关于Ios将标签(歌曲标题)从右侧移动到左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20209149/