Q:

Color Animation of UILabel in swift

I would like to have a setup where a UILabel fill the width of the screen and is of color red. When a button is tapped I want the red label to move to the right off the screen while at the same time a UILabel of Color green comes in from the left of the screen.
The only way I can think of doing this is having two different UILabels and animating them to move off and on the screen. 
Can I do this using just the one UILabel but fixed on the screen and just animated a Color change within that UILabel so it looks like the red has moved off screen to the right and the green has moved onscreen from the left?

A:

As far as I know, you need to use two separate labels. Here is how you can do the animation:
You can put the green label on the screen in the same spot with the same constraints as the red label and then set it to be off-screen at first (Run this code in viewDidLoad):
playAgainButton.center = CGPointMake(playAgainButton.center.x - 500, playAgainButton.center.y)

It sounds to me like you want the red label to move from on screen to the left off of the screen and the green label to move from off-screen to the left on to the screen...Here is the animation:
UIView.animateWithDuration(0.5, animations: { () -> Void in

        self.redLabel.center = CGPointMake(self.redLabel.center.x + 500, self.redLabel.center.y)

        self.greenLabel.center = CGPointMake(self.redLabel.center.x + 500, self.greenLabel.center.y)

    })

You can always mess with the animations to change the duration (I have it set to 0.5 seconds)
Hope this helps!

