将 MarqueeLabel 转换为 Swift 时枚举错误 1.2 语法
Error in enumerate when converting MarqueeLabel to Swift 1.2 Syntax
我想在用 Swift 1.2 编写的应用程序中为标签添加选取框效果。我找到了这个库 MarqueeLabel Swift 但它在 Swift 2 中。
除了一个错误,我几乎转换了所有错误。
现在显示的唯一错误是:
'[(layer: CALayer, anim: CAKeyframeAnimation)]' does not have a member
named 'enumerate'
错误显示代码是:
// Call scroller
var scrolls = scroller(interval: interval, delay: delay)
// Perform all animations in scrolls
for (index, scroll) in scrolls.enumerate() {
let layer = scroll.layer
let anim = scroll.anim
// Add callback to single animation
if index == 0 {
anim.setValue(completion as AnyObject, forKey: MarqueeKeys.CompletionClosure.rawValue)
anim.delegate = self
}
// Add animation
layer.addAnimation(anim, forKey: "position")
}
请帮我改正。
提前致谢。
Swift 1.2 使用此语法:
for (index, scroll) in enumerate(scrolls) {
我想在用 Swift 1.2 编写的应用程序中为标签添加选取框效果。我找到了这个库 MarqueeLabel Swift 但它在 Swift 2 中。 除了一个错误,我几乎转换了所有错误。
现在显示的唯一错误是:
'[(layer: CALayer, anim: CAKeyframeAnimation)]' does not have a member named 'enumerate'
错误显示代码是:
// Call scroller
var scrolls = scroller(interval: interval, delay: delay)
// Perform all animations in scrolls
for (index, scroll) in scrolls.enumerate() {
let layer = scroll.layer
let anim = scroll.anim
// Add callback to single animation
if index == 0 {
anim.setValue(completion as AnyObject, forKey: MarqueeKeys.CompletionClosure.rawValue)
anim.delegate = self
}
// Add animation
layer.addAnimation(anim, forKey: "position")
}
请帮我改正。
提前致谢。
Swift 1.2 使用此语法:
for (index, scroll) in enumerate(scrolls) {