UIKit is Apple's foundational framework for building user interfaces in iOS, iPadOS, tvOS, and watchOS applications. It provides the window and view architecture needed to display content on screen, the infrastructure to handle user interactions through touch and gestures, and the tools to manage your app's data and content flow. Understanding UIKit is essential even in the SwiftUI era — many production apps combine both frameworks, and iOS 26 deepened that integration further with automatic @Observable tracking in layout methods and a new updateProperties() lifecycle phase. UIKit's view controller lifecycle, Auto Layout system, compositional collection views, and diffable data sources remain the standard for complex, high-performance interfaces.
What This Cheat Sheet Covers
This topic spans 33 focused tables and 296 indexed concepts, 185 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: View Hierarchy and Core View Classes
The UIView is the atomic unit of every UIKit interface; every visible element is a subview sitting inside a tree rooted at a UIWindow. Understanding how views are added, layered, and positioned in this hierarchy is the prerequisite for everything else in UIKit.
| Class | Example | Description | |
|---|---|---|---|
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))view.backgroundColor = .red | • The fundamental building block for all visual elements • manages a rectangular area on screen and handles drawing and touch events | ||
parentView.addSubview(childView) | • Adds a view as a subview to another view's hierarchy • child appears on top of the parent | ||
childView.removeFromSuperview() | • Removes a view from its parent's subview hierarchy • automatically releases strong references | ||
let label = UILabel()label.text = "Hello" | • Displays one or more lines of read-only text • supports attributed strings and custom fonts | ||
let imageView = UIImageView(image: UIImage(named: "photo")) | Displays a single image or animates a sequence of images | ||
let stack = UIStackView(arrangedSubviews: [view1, view2])stack.axis = .vertical | • Arranges views in horizontal or vertical layouts without manual constraints • automatically manages spacing and alignment | ||
view.frame = CGRect(x: 50, y: 100, width: 200, height: 150) | • Position and size in the parent's coordinate system • avoid setting when using Auto Layout | ||
let size = view.bounds.size | • Position and size in the view's own coordinate system • origin typically (0, 0) | ||
view.center = CGPoint(x: 150, y: 200) | The center point of the view in its parent's coordinate system | ||
view.transform = CGAffineTransform(rotationAngle: .pi / 4) | • Affine transformation for rotation, scaling, or translation • applied relative to center point | ||
let children = parentView.subviews | Read-only array of all direct child views in the order they were added | ||
if let parent = view.superview { } | • Reference to the immediate parent view • nil if the view has no parent | ||
parentView.bringSubviewToFront(childView) | Moves a subview to the top of the draw order so it renders on top of siblings | ||
parentView.sendSubviewToBack(backgroundView) | Moves a subview behind all other sibling views in the draw order | ||
parentView.insertSubview(newView, at: 1) | Inserts a subview at a specific position in the subviews array, controlling z-order |