2017-08-01 10 views
0

ログインページの画面に表示するメッセージの文字列リストを実装しようとしています。ユーザーが決定した場合、これらのメッセージがスクロールできるようにする必要があります。私は自分のテキストにラベルを使用しています。ユーザーがスクロールしない場合、メッセージは自動的にスクロールします。私はiCarouselを使ってみましたが、私が望む効果は得られません。即座にメッセージをスクロールする方法

答えて

0

あなたはLibray https://github.com/cbpowell/MarqueeLabel を使用することができますか簡単にあなたも自動スクロール可能なラベル

func startAnimation() 
{ 
    //Animating the label automatically change as per your requirement 

    DispatchQueue.main.async(execute: { 

     UIView.animate(withDuration: 10.0, delay: 1, options: ([.curveLinear, .repeat]), animations: { 
      () -> Void in 
      self.demoLabel.center = CGPoint(x: 0 - self.demoLabel.bounds.size.width/2, y: self.demoLabel.center.y) 
     }, completion: nil) 
    }) 
} 

使用

class ViewController: UIViewController { 

    let demoLabel: UILabel = { 

     let label = UILabel() 
     label.translatesAutoresizingMaskIntoConstraints = false 
     label.font = .systemFont(ofSize: 14) 
     label.textColor = .green 
     label.text = "This is the demo label for testing automatically scrolling of uilabel when user not clicked on label if user click on label the scrolling is stoped." 
     return label 
    }() 



    override func viewDidLoad() { 
     super.viewDidLoad() 
     view.addSubview(demoLabel) 
     startAnimation() 
} 
+0

おかげのようなあなた自身の自己作ることができ、それが働きました! –

関連する問題