how Marquee text of label on swift?

后端 未结 4 516
我寻月下人不归
我寻月下人不归 2021-01-17 08:42

I want to create a marquee label in Swift. I tried some codes but could not get it to work.

I also can do this with animation but I have problem with repeating it.

4条回答
  •  独厮守ぢ
    2021-01-17 09:27

    I don't know why I got 2 - ?!???

    I tried many things. that doesn't matter anymore...

    I found this 5 min ago and thats my answer for using animation instead of marquee. but on iOS marquee is a tough problem !

    here is the link that solved my repeating animation problem

    I used this code and it Works ! wish to help others too.

    on ViewdidLoad :

      if let aLabel = self.txtAmarFull {
            aLabel.pushTransition(3)
    
        }
    

    on Body:

    extension UIView {
    func pushTransition(duration:CFTimeInterval) {
        let animation:CATransition = CATransition()
        animation.timingFunction = CAMediaTimingFunction(name:
            kCAMediaTimingFunctionEaseInEaseOut)
        animation.type = kCATransitionMoveIn
        animation.subtype = kCATransitionFromLeft
        animation.duration = duration
        animation.repeatCount = 99
        self.layer.addAnimation(animation, forKey: kCATransitionPush)
    }
    

    my label name is : txtAmarfull

提交回复
热议问题