簡體   English   中英

iOS Swift-從右到左自動滾動UILabel

[英]iOS Swift - Autoscroll UILabel from Right to Left

這兩個列需要自動滾動(如選取框)。 但我在執行此操作時遇到問題。 我找到了兩種解決方案,但不幸的是,這些解決方案均無效。

  1. https://github.com/cbess/AutoScrollLabel
  2. https://github.com/cbpowell/MarqueeLabel

任何幫助是極大的贊賞。

在此處輸入圖片說明

嘗試這個:

    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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM