O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Aaron Hillegass, Christian Keur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating Constraints

In this section, you are going to extend your animation to have the nextQuestionLabel property fly in from the left side of the screen and the currentQuestionLabel fly out to the right side of the screen whenever the user presses the Next Question button. In doing so, you will learn how to animate constraints.

First, you need a reference to the constraints that need to be modified. So far, all of your @IBOutlets have been to view objects. But outlets are not limited to views – in fact, any object in your interface file can have an outlet, including constraints.

At the top of ViewController.swift, declare two outlets for the two labels’ centering constraints.

@​I​B​O​u​t​l​e​t​ ​v​a​r​ ​c​u​r​r​e​n​t​Q​u​e​s​t​i​o​n​L​a​b​e​l​:​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required