Spring Animations

iOS has a powerful physics engine built into the SDK, and one of the easiest ways to use it is with the new spring animations. This type of animation has a timing function like that of an actual spring. You will use this to animate the text field dropping in from the top of the screen, as if it was attached to a spring.

In BNRHypnosisViewController.m, add a property for the text field to the class extension and update loadView to store the reference to the text field. Then start with the text field offscreen:

@​i​n​t​e​r​f​a​c​e​ ​B​N​R​H​y​p​n​o​s​i​s​V​i​e​w​C​o​n​t​r​o​l​l​e​r​ ​(​)​ ​<​U​I​T​e​x​t​F​i​e​l​d​D​e​l​e​g​a​t​e​>​
@​p​r​o​p​e​r​t​y​ ​(​n​o​n​a​t​o​m​i​c​,​ ​w​e​a​k​)​ ​U​I​T​e​x​t​F​i​e​l​d​ ​*​t​e​x​t​F​i​e​l​d​;​ ...

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.