UIKit Fundamentals

June 02, 2026 1 min read

UIKit is the long-standing iOS UI framework. Everything on screen is a UIView arranged in a tree.

Common views

  • UILabel — text.
  • UIButton — tappable actions.
  • UIImageView — images.
  • UITextField — single-line input.
  • UIStackView — auto-arranges children in a row/column.

Creating a view in code

let label = UILabel()
label.text = "Welcome"
label.font = .boldSystemFont(ofSize: 22)
label.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(label)

Handling a button tap

button.addTarget(self, action: #selector(tapped), for: .touchUpInside)
@objc func tapped() { print("Button tapped") }
Tip: UIStackView dramatically reduces layout code — group related views inside it.

Summary

UIKit builds UI from a hierarchy of UIViews. You met the common controls and how to add and wire them.