UIKit
By Apple
UIKit is Apple's original framework for constructing graphical user interfaces on iOS, iPadOS, and tvOS, providing view controllers, event handling, and a large library of standard interface components in an imperative, object-oriented…
Definition
UIKit is Apple's original framework for constructing graphical user interfaces on iOS, iPadOS, and tvOS, providing view controllers, event handling, and a large library of standard interface components in an imperative, object-oriented programming style. It has been the primary way to build iOS app interfaces since the original iPhone SDK and remains widely used alongside the newer, declarative SwiftUI framework.
Overview
UIKit predates SwiftUI by over a decade and was the only way to build iOS interfaces from the App Store's launch until SwiftUI's introduction. It follows an imperative, class-based model: developers instantiate view objects such as `UIView`, `UILabel`, and `UIButton`, arrange them using Auto Layout constraints or manual frame math, and write explicit code to update those views whenever the underlying data changes. Interface structure is often defined visually in Interface Builder's storyboard and XIB files, or programmatically in code, and both approaches remain fully supported. Mechanically, UIKit organizes an app around `UIViewController` instances, each managing a screen's view hierarchy and lifecycle events like `viewDidLoad` and `viewWillAppear`. User interaction is handled through target-action patterns and delegate protocols — a button's tap target calls a specific method, a table view's data source and delegate objects supply rows and respond to selection. Auto Layout resolves view positions and sizes through a constraint-solving system that can express relationships like a view's leading edge sitting 16 points from its superview's leading edge, across arbitrary screen sizes. UIKit's main counterpart within Apple's own ecosystem is SwiftUI, which offers a declarative alternative built around state-driven rendering rather than manual view mutation. UIKit remains the framework with the deepest capability surface, broadest third-party library support, and the most predictable behavior across older iOS versions, since it has had years longer to mature. Outside Apple's platforms, it parallels Android's older View system in relationship to Jetpack Compose — both are the imperative predecessor being gradually supplemented by a declarative successor. In practice, UIKit is used in the large body of existing iOS apps built before SwiftUI existed, in apps needing precise control over animation timing, custom drawing, or complex gesture recognition, and in components where SwiftUI's API coverage still has gaps, such as certain camera, text-editing, or collection-view customizations. Many teams adopt a hybrid approach, writing new screens in SwiftUI while maintaining existing UIKit screens and wrapping UIKit components inside SwiftUI views where needed. The trade-offs are largely about development speed and boilerplate: UIKit requires more code to achieve the same result as SwiftUI for typical screens, and keeping view state and UI in sync is the developer's responsibility rather than something the framework manages automatically. For teams starting fresh with straightforward interfaces, SwiftUI usually offers faster iteration; for teams maintaining large legacy codebases or needing fine-grained control that SwiftUI does not yet expose, UIKit remains the more capable choice.
Key Features
- Imperative, class-based view and view controller architecture
- Auto Layout constraint system for adaptive interface positioning
- Target-action and delegate patterns for handling user interaction
- Interface Builder storyboards and XIBs for visual layout design
- Deep, mature API surface covering over a decade of iOS features
- Fine-grained control over custom drawing, gestures, and animation
- Broad third-party library and tooling ecosystem
- Interoperates with SwiftUI views via hosting and representable wrappers