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. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
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) |