UIKit Knowledge

Kip Landergren

(Updated: )

My UIKit knowledge base explaining how interfaces are built on iOS using view components, the render loop, animations, and interactions.

Contents

Overview

UIKit is the main user interface library used for iOS application development. It makes available classes that represent user interface components like views, labels, and buttons, and provides a mechanisms for layout, animations, and user interactivity. Views are assembled into a discrete “view hierarchy” that forms the backbone for relaying events to the appropriate view-controlling object, an instance of UIViewController.

Layout—how views are arranged on screen to create an app user interface—is accomplished by three major components working together:

Together these components are known as Auto Layout.

Animations are the movement of view objects to create a sense of realism while interacting with a user interface. Most UIKit view components are animatable, or at least have animatable properties, and there are concrete classes that allow for control and customization of animations.

Users may interact with applications through many mediums with the primary being touch. Touches are recognized and managed through hit-testing to determine which view was touched (“hit”) and by “Gesture Recognizers” which decouple the recognition of a sequence of touches from the action taken as a result.

Core Idea

Create a core set of performant classes with an easy-to-use API for developers to build applications with.

Key Concepts

View Components

Group like functionality into classes and protocols that allow for easy customization and extensibility.

Render Loop

120Hz process to update contents on the screen.

Constraints and View Layout

See Auto Layout Knowledge.

Animations

Changes in the user interface, especially in response to interaction, add a liveliness and feeling of realness that makes things better.

Touches, Presses and Gestures

User interaction through on screen manipulation.

Hit Testing

How a UIKit determines which UIView received a gesture.

Accessibility

Views can be augmented with additional data to convey information across many accessibility channels.

Application Life Cycle

UIKit marshals application life cycle events and transitions through two protocols: UIApplicationDelegate and UISceneDelegate.

Scenes, introduced in iOS 13, are the abstraction layer for an application supporting multiple windows. UIKit still talks to UIApplicationDelegate for life cycle events, but now will scope a subset to the UIWindowScene being interacted with and relay them through the UISceneDelegate. In short, the traditional role of UIApplicationDelegate has been split to now include UISceneDelegate.

Multi-window support is opt-in and may be configured through an application’s Info.plist.

View Components

UIButton

An interactable view element.

UIFont

Styles text.

UIImageView

Makes it easy to present an image.

UILabel

UILabel is the placeholder for text.

Animations

Timing Curves

Timing Curves are mappings between time and progress. When an animation changes its timing curve (e.g. shifting from an easeIn to a linear) progress will be held constant so there is no discontinuous jump.

UIKit Terminology

Anchor
a factory class for creating layout constraints from view attributes
Baseline
line at bottom of text
Layout Constraint
an equation that defines how a view attribute should exist, often in relationship to another view attribute
Leading Edge
the first edge encountered when scanning in reading order (locale-dependent; changes with right-to-left or left-to-right languages)
Trailing Edge
the last edge encountered when scanning in reading order (locale-dependent; changes with right-to-left or left-to-right languages)
View Attribute
part of the object’s visual representation, typically corresponding to an edge or dimension, that should be used to get the value for the layout constraint

Related Documents