如何实现MarqueeLabel在 iOS 中。我在 Objective-C 中找到了示例,但我使用的是 Swift。
最佳答案
在您的项目中快速创建选取框添加下面的类 https://github.com/cbpowell/MarqueeLabel
为此,首先添加 pod:pod 'MarqueeLabel'
。
并在您的项目中执行 pod 更新
。
然后在您的工作文件中导入 pod:
导入 MarqueeLabel
创建一个标签并在 Storyboard中将自定义类设置为 MarqueeLabel
。
然后:
@IBOutlet weak var marqueeLabel:MarqueeLabel!
在 ViewDidLoad 中添加:
marqueeLabel.type = .Continuous
marqueeLabel.scrollDuration = 5.0
marqueeLabel.animationCurve = .EaseInOut
marqueeLabel.fadeLength = 10.0
marqueeLabel.leadingBuffer = 30.0
marqueeLabel.trailingBuffer = 20.0
关于ios - 如何使用swift在IOS中实现跑马灯标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33007063/