Lesson 9

Introduction to UIKit and Adaptive Layout

With the launch of iOS8, Apple has made it possible to build an application that can run on any device with a single storyboard. In Apple's terminology, the application adapts to the device it is running on. Prior to iOS8, it was common to have different storyboards for each device family.

Instead of specifying explicit sizes and positions for UI elements, with adaptive layout you specify constraints between the user interface elements of your view and have iOS apply these constraints at run time to work out the size and position the elements. A constraint is a mathematical description of the relationship between elements.

Most of the time, you apply these constraints using Interface Builder, but it is possible to specify these constraints programmatically in your code by creating instances of NSLayoutConstraint. Creating NSLayoutConstraint instances programmatically is outside the scope of this book. If you are interested in learning more about creating layout constraints programmatically, refer to the NSLayoutConstraint Class Reference at:

https://developer.apple.com/library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/

Introducing the UIKit Framework

A framework is a collection of classes that you can use to write your apps. Apple provides a large number of frameworks that enforce consistent implementation of features across applications from different developers. All the familiar user interface features ...

Get Swift iOS 24-Hour Trainer 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.