[英]iOS Swift - Autoscroll UILabel from Right to Left
這兩個列需要自動滾動(如選取框)。 但我在執行此操作時遇到問題。 我找到了兩種解決方案,但不幸的是,這些解決方案均無效。
任何幫助是極大的贊賞。
嘗試這個:
let label = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
label.frame = CGRectMake(320, 100, 200, 60)
label.text = "This is my music line"
self.view!.addSubview(label)
NSTimer.scheduledTimerWithTimeInterval(2.0, target: self, selector: #selector(self.LabelAnimate), userInfo: nil, repeats: true)
}
func LabelAnimate() {
UIView.animateWithDuration(3.0, delay: 0.0, options: .TransitionNone, animations: {() -> Void in
self.label.frame = CGRectMake(-320, 100, 200, 60)
}, completion: {(isDone: Bool) -> Void in
self.label.frame = CGRectMake(320, 100, 200, 60)
})
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.