Created
January 9, 2017 07:18
-
-
Save edwardean/ec0e140d2c723117d4a1a7d5aa9f5717 to your computer and use it in GitHub Desktop.
UILabel text animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let label = UILabel() | |
| label.frame = CGRect(x: 0.0, y: 0.0, width: 400.0, height: 75.0) | |
| label.backgroundColor = UIColor.whiteColor() | |
| label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleTitle1) | |
| label.textAlignment = .Center | |
| label.text = "Hello, world!" | |
| let fadeTransition = CATransition() | |
| fadeTransition.duration = 0.2 | |
| CATransaction.begin() | |
| CATransaction.setCompletionBlock({ | |
| label.text = "Goodnight, moon..." | |
| label.layer.addAnimation(fadeTransition, forKey: kCATransition) | |
| }) | |
| label.text = "" | |
| label.layer.addAnimation(fadeTransition, forKey: kCATransition) | |
| CATransaction.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment