Apple Watch滚动自动收报机标签

时间:2015-06-30 18:52:05

标签: ios user-interface apple-watch

是否可以将滚动滚动条文本视图添加到Apple Watch应用程序中?Ticker text

1 个答案:

答案 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)

    }

}