LoginSignup
5
6

More than 5 years have passed since last update.

Swiftでテキストをニコニコ風に表示する

Posted at

画面外の位置から画面の外に位置を動かします

// UILabelをニコニコ風に流す
func  nicoAnimation(label: UILabel) {
    label.frame.origin.x = UIScreen.main.bounds.size.width
    // 文字の流れるスピードを調整する
    UIView.animate(withDuration: 8, animations: { () -> Void in
        label.frame.origin.x = -UIScreen.main.bounds.size.width
    }, completion: { finished in
        // 繰り返し
        self.nicoAnimation(label: label)
    })
}

storyboaradを使用する際はauto layoutを外す

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6