Activity 1
Create an adaptive card
Lay out an icon, multiline title, subtitle, and button without fixed text heights. Test several content-size categories.
Hint: Let intrinsic sizes work and decide which element may compress first.
UIKit Development
Create adaptive interfaces with anchors, layout guides, intrinsic content size, and constraint priorities.
Before you begin
Learning stage
Auto Layout solves a set of relationships to produce frames. Prefer constraints that describe intent—leading to a margin, vertical spacing between peers, or equal widths—over fixed coordinates. A complete layout provides enough horizontal and vertical information without over-constraining the same degree of freedom.
Use safeAreaLayoutGuide when content must avoid bars and system obstructions, layoutMarginsGuide for consistent internal spacing, and readableContentGuide for comfortable long-form text. Directional leading and trailing anchors adapt to right-to-left languages; left and right usually do not.
Labels and controls provide intrinsic content sizes. Content-hugging priority resists growing beyond that size, while compression-resistance priority resists shrinking below it. When optional constraints compete, priorities communicate the intended compromise. Debug from the first broken constraint and test long localized text plus accessibility sizes.
Learning stage
This header adapts to long text and keeps its action visible without fixed frames.
let titleLabel = UILabel()
titleLabel.numberOfLines = 0
titleLabel.font = .preferredFont(forTextStyle: .title2)
let actionButton = UIButton(configuration: .bordered())
actionButton.configuration?.title = "Continue"
actionButton.setContentCompressionResistancePriority(.required, for: .horizontal)
let row = UIStackView(arrangedSubviews: [titleLabel, actionButton])
row.axis = .horizontal
row.alignment = .center
row.spacing = 16
row.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(row)
NSLayoutConstraint.activate([
row.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
row.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
row.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 24)
])Learning stage
Connect the UIKit concept to complete, maintainable application features.
Learning stage
Identify lifecycle, ownership, identity, layout, accessibility, and user-experience risks.
Learning stage
Build the behavior in a small Xcode project and inspect it across realistic states.
Activity 1
Lay out an icon, multiline title, subtitle, and button without fixed text heights. Test several content-size categories.
Hint: Let intrinsic sizes work and decide which element may compress first.
Activity 2
Intentionally add incompatible width constraints, read the console report, identify the conflict, and replace it with an intentional priority.
Hint: Give constraints identifiers while experimenting.
Learning stage
Answer each question before revealing the explanation.
QUESTION 1
When it must avoid system bars and obstructions
The safe area represents the unobscured part of a view and is adjusted by system containers.
QUESTION 2
How strongly a view resists becoming smaller than its intrinsic content size.
Higher-priority views are protected when horizontal or vertical space becomes constrained.
Learning stage
Explain the design in terms of lifecycle, identity, ownership, system behavior, and trade-offs.
Short answer: Express relationships with anchors and guides, rely on intrinsic size, set priorities intentionally, and test stressful content.
I use directional margins and safe areas, avoid fixed text dimensions, choose hugging and compression behavior based on product importance, and inspect both ambiguity and broken constraints. I test long localization, Dynamic Type, rotation, and split-screen widths.
Possible follow-ups
Learning stage
Auto Layout is a relationship system. Good constraints express design intent, use the right guides, and define how content should compromise under pressure.