Another Label

The animation works great the first time the Next Question button is pressed, but there is no visible animation on subsequent button presses since the label already has an alpha value of 1. In this section, you are going to add another label to the interface. When the Next Question button is pressed, the existing label will fade out while the new label (with the text of the next question) will fade in.

At the top of ViewController.swift, replace your declaration of a single label with two labels.

@IBOutlet var questionLabel: UILabel!
@IBOutlet var currentQuestionLabel: UILabel!
@IBOutlet var nextQuestionLabel: UILabel!

@IBOutlet var answerLabel: UILabel!

Xcode flags four places where you need to replace questionLabel ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.