Animate text change in UILabel

后端 未结 14 1275
[愿得一人]
[愿得一人] 2020-11-28 17:56

I\'m setting a new text value to a UILabel. Currently, the new text appears just fine. However, I\'d like to add some animation when the new text appears. I\

14条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 18:35

    Swift 2.0:

    UIView.transitionWithView(self.view, duration: 1.0, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {
        self.sampleLabel.text = "Animation Fade1"
        }, completion: { (finished: Bool) -> () in
            self.sampleLabel.text = "Animation Fade - 34"
    })
    

    OR

    UIView.animateWithDuration(0.2, animations: {
        self.sampleLabel.alpha = 1
    }, completion: {
        (value: Bool) in
        self.sampleLabel.alpha = 0.2
    })
    

提交回复
热议问题