是否可以将滚动滚动条文本视图添加到Apple Watch应用程序中?
答案 0 :(得分:2)
这是不可能的。但有一个工作......
class InterfaceController: WKInterfaceController {
@IBOutlet var label: WKInterfaceLabel!
let fullText = "i am a long text and i am scrollable horizontally lol."
var scrolledText: String?
var timer: NSTimer?
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
scrolledText = fullText
timer = NSTimer.scheduledTimerWithTimeInterval(0.2, target: self, selector: Selector("timerDidFire:"), userInfo: nil, repeats: true)
label.setText(scrolledText)
}
override func didDeactivate() {
timer?.invalidate()
}
func timerDidFire(timer: NSTimer) {
if scrolledText!.characters.count > 1 {
scrolledText!.removeAtIndex(scrolledText!.startIndex)
} else {
scrolledText = fullText
}
label.setText(scrolledText)
}
}