If you are preparing for an iOS or macOS developer interview today, SwiftUI is no longer optional; it is the standard. Companies no longer just ask “do you know how to use it?”, but rather “do you understand how its state management and rendering engine work?”.
To help you master the technical interview, I have compiled a massive collection of questions. In this first part of our series, we cover the 200 essential questions in a “Lightning Round” format: direct questions with concise answers to refresh your memory quickly.
🟢 Level 1: Fundamental Concepts
These questions verify if you understand the philosophy behind the framework.
- What is SwiftUI? It is a declarative user interface framework created by Apple to build UIs across all its platforms (iOS, macOS, watchOS, tvOS) using Swift.
- What is the main difference between SwiftUI and UIKit? SwiftUI is declarative (you describe what you want the UI to do), while UIKit is imperative (you describe how to build and modify it step-by-step).
- What does it mean that SwiftUI is “Declarative”? It means the code defines the final state of the interface, and the system handles rendering the changes when the state varies, rather than managing transitions manually.
- Why are Views in SwiftUI
Structsand notClasses? Structs are value types, lighter, and faster to create. This allows SwiftUI to recreate them thousands of times without performance impact, facilitating the “diffing” system used to update the screen. - What is the
Viewprotocol? It is the base protocol of SwiftUI. Anything drawn on the screen must conform toViewand define abodyproperty. - What type does the
bodyproperty return? It returnssome View. - What does
some View(Opaque Return Type) mean? It indicates that the property returns something that conforms to theViewprotocol, but hides the concrete type (which could be very complex, likeVStack<TupleView<...>>) from the external compiler. - What is a
Modifier? It is a method that creates a new view by applying a change to the original view (e.g.,.padding(),.background()). - Does the order of modifiers matter? Yes, absolutely.
.background(Color.red).padding()is different from.padding().background(Color.red). - What is the
Canvasin Xcode? It is the interactive preview area that shows SwiftUI code changes in real-time without needing to compile the entire app. - What is
PreviewProvider(or the#Previewmacro)? It is the code that generates the preview in the Canvas. Since Xcode 15, the#Previewmacro is used to simplify the syntax. - Does SwiftUI support Auto Layout? Not directly. SwiftUI uses its own layout system based on Stacks, Spacers, and Alignment, although underneath it uses technologies similar to the layout engine.
- How do you debug a view in SwiftUI? You can use
Self._printChanges()inside the view body to see what caused the redraw, or use Xcode’s View Debuggers. - What is the basic lifecycle of a view? Initialization ->
onAppear-> Updates (due to state changes) ->onDisappear. - What is a
Group? A container that groups views without applying any visual layout (it doesn’t stack them), useful for overcoming the 10-view limit per container or applying modifiers to multiple views at once.
🔵 Level 2: State Management (The Core of SwiftUI)
If you fail here, you fail the interview. Understanding data flow is vital.
- What is the “Source of Truth”? The concept that data should exist in a single place, and views should only read or react to that data, not duplicate it.
- What does
@Statedo? It declares a mutable property owned by the view. When it changes, SwiftUI automatically redraws the view. It is used for simple local states (e.g., a toggle). - Why must
@Statebe declared asprivate? Because it is designed to be used only internally by the view that creates it. - What is
@Binding? It allows a child view to read and write a value owned by a parent view without owning the data itself. It is a read/write reference. - What is the difference between
@ObservedObjectand@StateObject?@StateObjectensures the object is created only once and persists even if the view redraws.@ObservedObjectdoes not guarantee persistence if the owning view is destroyed and recreated; it is used for injected objects that already exist. - When would you use
@EnvironmentObject? For data that needs to be accessed by many views in the hierarchy (like a user profile or theme settings) without having to pass them manually from parent to child (prop drilling). - What protocol must a class conform to in order to use
@Published?ObservableObject. - What does the
@Publishedproperty do? It automatically notifies observers when the variable’s value changes, triggering UI updates. - What is
@Environment? It allows reading values from the system environment, such as dark mode (.colorScheme), horizontal size class, or locale settings. - What is
@AppStorage? A property wrapper that connects a variable directly toUserDefaults. If the value in UserDefaults changes, the view updates. - What is
@SceneStorage? Similar to@AppStoragebut for persisting the state of a specific scene (useful for state restoration in iPad multitasking). - What is
Binding.constant(value)? It creates an immutable binding, useful primarily for Previews where you need to pass a binding but don’t need real logic. - How do you communicate changes from a child view to a parent without Bindings? You can use Closures(callbacks) or
PreferenceKeys. - What are
PreferenceKeys? An advanced mechanism to pass data up the hierarchy (from child to parent), opposite to the normal data flow. - Is it good practice to use Singletons in SwiftUI? Generally not for dependency injection into views. It is better to use
@EnvironmentObjector injection in the initializer to facilitate testing.
🟠 Level 3: Layout and Design
- What are the three main stacks?
VStack(Vertical),HStack(Horizontal),ZStack(Depth/Overlay). - What does a
Spacerdo? It occupies all available space on the axis of its containing stack, pushing the rest of the content. - How does
Framework? It modifies the size proposed to the view..frame(maxWidth: .infinity)makes the view take up all possible width. - What is
GeometryReader? A container that gives you access to the size and coordinates of its parent view. Useful for complex responsive designs. - What is the main problem with using
GeometryReadereverywhere? It can break SwiftUI’s natural automatic layout and is performance-heavy if abused; it often tends to take up all available space. - What are
LazyVStackandLazyHStack? Stacks that only render views that are currently visible on the screen. Essential for long scrolling lists to improve performance. - How do you create a Grid? Using
LazyVGridorLazyHGridalong withGridItem. - What is the
SafeArea? The areas of the screen obstructed by system elements (the notch, the Dynamic Island, the home bar). - How do you ignore the Safe Area? Using the
.ignoresSafeArea()modifier. - How do you prioritize which view shrinks if there is no space? Using
.layoutPriority(Double). Views with higher priority keep their size; those with lower priority shrink or truncate. - What is the
.overlay()modifier? Places a view on top of another (in front of the user), similar to a ZStack but coupled to the size of the original view. - What is the
.background()modifier? Places a view behind another. - How do you round the corners of a view?
.cornerRadius()(deprecated) or.clipShape(RoundedRectangle(...)). - How do you apply shadows? With the
.shadow()modifier. - What is
ImageScale? It defines the relative size of SF Symbols (small, medium, large) independently of their font size.
🟣 Level 4: Lists and Navigation
- What is the difference between
ListandForEachinside a ScrollView?Listhas a native system appearance (UIKit table style) and built-in loading optimizations (lazy).ScrollView + ForEachis fully customizable but does not recycle cells automatically unless you useLazyVStack. - What protocol must elements of a
Listconform to?Identifiable, or you must provide an explicitid: \.self. - What is the purpose of the
idproperty inIdentifiable? So SwiftUI knows how to distinguish which row is which, especially when animating changes, insertions, or deletions. - How do you handle navigation in iOS 16+? With
NavigationStackandnavigationDestination(for:). - Why was
NavigationViewdeprecated? It had inconsistent behaviors between iPhone and iPad (split view) and handling programmatic navigation (deep linking) was difficult. - How do you perform programmatic navigation (go to a screen via code)? Using a
NavigationPathor a binding to an array of data insideNavigationStack. - What is
NavigationLink? The button or area that triggers the transition to a new view within a navigation stack. - How do you show a modal window (Sheet)? Using the
.sheet(isPresented: content:)or.sheet(item: content:)modifier. - Difference between
.sheetand.fullScreenCover?.sheetshows the card-style view (part of the previous view is seen behind),.fullScreenCoveroccupies the entire screen. - What is
TabView? The equivalent of UITabBarController, allows navigation via bottom tabs (or side tabs on iPad/macOS). - How do you create a paginated image carousel? Using
TabViewwith the.tabViewStyle(.page)style. - How do you add a title to the navigation bar? With the
.navigationTitle("Title")modifier applied to the view insidethe stack. - How do you add buttons to the navigation bar? With
.toolbar { ... }andToolbarItem. - How do you show an alert? With the
.alert()modifier, bound to a boolean state or an optional error object. - How do you implement “Pull to Refresh”? Adding the
.refreshable { ... }modifier to a List or ScrollView.
🔴 Level 5: Interoperability and Advanced
- How do you use a UIKit view in SwiftUI? Creating a
structthat conforms toUIViewRepresentable. - What methods must you implement in
UIViewRepresentable?makeUIView(context:)andupdateUIView(_:context:). - What is the
CoordinatorinUIViewRepresentable? It acts as the bridge to receive events from UIKit (like delegates or targets) and communicate them back to SwiftUI. - How do you use a UIViewController in SwiftUI? Using
UIViewControllerRepresentable. - How do you use a SwiftUI view in a UIKit project? Wrapping it in a
UIHostingController. - What is
AnyLayout(iOS 16)? A type that allows dynamically switching between layout types (e.g., from VStack to HStack) while maintaining the identity of views for fluid animations. - How do you manage explicit animations? Wrapping the state change in a
withAnimation { ... }block. - What are implicit animations? The
.animation(.default, value: variable)modifier that automatically animates whenvariablechanges. - What does
matchedGeometryEffectdo? It allows animating the movement of a view from one position/hierarchy to a different one, creating fluid “Hero animation” transitions. - What is
TimelineView? A view that updates periodically according to a schedule, useful for clocks or complex time-based animations. - What is
Canvas(the view, not the preview)? A view for high-performance 2D drawing (similar todrawRectin CoreGraphics) using an immediate mode drawing context. - How do you handle asynchronous tasks when a view appears? Using the
.taskmodifier. It is better thanonAppearbecause it automatically cancels the task if the view disappears before finishing. - What is
AsyncImage? A native view for downloading and displaying images from a URL. - What is the limitation of
AsyncImage? It does not have built-in disk caching by default (only temporary memory while the view lives). For real caching, external libraries or custom implementations are usually used. - What is
ViewBuilder? A function attribute (result builder) that allows constructing views from closure blocks, enabling DSL-like syntax (like inside a VStack). - Can you create your own containers like VStack? Yes, using the
Layoutprotocol (iOS 16+). - What is
FocusState? A property wrapper to control keyboard focus on text fields (making the keyboard appear or disappear programmatically). - How do you support Dark Mode in custom colors? Defining the color in the Asset Catalog with “Any” and “Dark” variants, or using semantic system colors (
.systemBackground). - What is Dynamic Type? The app’s ability to scale font size according to the user’s settings. SwiftUI supports this by default.
- How do you limit the number of lines in a text?
.lineLimit(n).
⚫ Level 6: Architecture and Data (Core Data / SwiftData)
- Is MVVM the only architecture for SwiftUI? No. Although it is the most common, patterns like “The Composable Architecture” (TCA) or Redux are also popular due to the declarative nature of SwiftUI.
- What is the role of the ViewModel in SwiftUI? Transforming model data into state ready for the view and handling business logic (user actions).
- What property wrapper is used to inject a Core Data context?
@Environment(\.managedObjectContext). - How do you fetch Core Data in a view? Using
@FetchRequest. - What is SwiftData? The modern successor to Core Data, designed purely for Swift and SwiftUI, released in iOS 17.
- How do you define a model in SwiftData? Using the
@Modelmacro before the class. - How do you query data in SwiftData inside a view? Using the
@Querymacro. - What problem do very large views in a single file have? The compiler takes longer to infer types, the preview is slow, and the code is hard to read. Extracting subviews is recommended.
- What is the difference between a computed property (var body: some View) and a subview struct? The structis better for performance because SwiftUI can cache it and optimize its redrawing independently. The computed property is always re-evaluated when the parent body changes.
- How do you test a SwiftUI view? It is difficult to Unit Test views. Using UI Tests (XCUITest) or using the library
ViewInspectorto inspect the hierarchy in unit tests is recommended. - What is the
.redacted(reason: .placeholder)modifier? It converts the view content into gray blocks, ideal for automatic loading states (skeletons). - How do you handle global errors? Often by injecting an error manager into the
Environmentor using a global state that triggers alerts in the root view. - What is
MainActor? An attribute that ensures code runs on the main thread. ViewModels (ObservableObject) are usually marked with@MainActorto ensure UI updates happen on the correct thread. - How do you optimize a list that lags when scrolling?
- Use
Identifiablecorrectly. 2. Reduce the complexity of each row. 3. Ensure images load asynchronously. 4. Avoid heavy calculations in thebody.
- Use
- What is
EquatableViewused for? It allows defining custom rules to decide if a view needs to be redrawn by comparing its old and new state, avoiding unnecessary renders.
⚪ Level 7: macOS and Multiplatform
- Does SwiftUI work the same on macOS as on iOS? 90% yes, but macOS has different paradigms (multiple windows, menu bar, mouse vs. touch events).
- What is
Settingsin theAppstructure? It defines the preferences/settings window on macOS (Command + ,). - How do you detect if you are on macOS or iOS at compile time? Using
#if os(macOS)…#endif. - How do you handle Mouse Hover on macOS/iPadOS? Using the
.onHover { isHovering in ... }modifier. - What is
Commandsin theAppstructure? It allows modifying the system menu bar (File, Edit, etc. menus) on macOS.
♿ Level 8: Accessibility (The Key Differentiator)
Big companies (and Apple) value this enormously. If you ignore this section, you are ignoring millions of users.
- How do you make a decorative image ignored by VoiceOver? Using the
.accessibilityHidden(true)modifier. - What is the difference between
.accessibilityLabeland.accessibilityValue? TheLabeldescribes what the element is (e.g., “Volume”), and theValuedescribes its current state (e.g., “50%”). - What is
.accessibilityHint? An optional instruction explaining what will happen if the user interacts with the element (e.g., “Double tap to mute”). - How do you group multiple text elements so VoiceOver reads them as a single sentence? Using the
.accessibilityElement(children: .combine)modifier. - What is Sort Priority in accessibility? It defines the order in which VoiceOver reads elements. It is controlled with
.accessibilitySortPriority(Double). - How do you support Dynamic Type in complex layouts that might break? Using
ViewThatFitsor detecting thesizeCategoryin the environment to switch fromHStacktoVStackif the font is too large. - What is
.accessibilityAddTraits? It adds characteristics to the element, such as.isButtonor.isHeader, so the screen reader knows how to treat it. - How do you test accessibility without a physical device? Using the “Accessibility Inspector” tool in Xcode.
- How do you make a custom button behave like a native button for VoiceOver? Ensuring it has the
.isButtontrait and does not hide its action. - What is “Reduce Motion” and how do you respect it in SwiftUI? It is a user preference to minimize motion sickness. It is read from
@Environment(\.accessibilityReduceMotion)and you should use it to disable or simplify animations.
🎨 Level 9: Advanced Graphics, Animations, and Layouts
- What is the
Animatableprotocol? It allows animating changes in properties that are not animatable by default (like vertices of a custom shape) by defininganimatableData. - What is
AnimatablePair? A type that allows animating two values simultaneously withinanimatableData(e.g., X and Y coordinates). - What is the difference between
.transitionand.animation?.animationsmooths the change of properties of an existing view (color, size)..transitiondefines how a view enters or leaves the hierarchy (fade in, slide out). - Why might a transition not work? Usually because the view is not actually being removed/inserted into the tree (e.g., using
opacityinstead of a conditionalif). - What is
Canvasin terms of graphics (SwiftUI 3.0+)? A view providing a high-performance immediate mode graphics context (similar todrawRectin Core Graphics), ideal for particles or complex drawing. - What is
TimelineViewand what is it used for in animations? It allows redrawing a view periodically (even frame-by-frame), useful for time-based animations or physics that don’t depend on state changes. - How do you create a Custom Shape? By creating a struct that conforms to
Shapeand implementingpath(in rect: CGRect). - What is a
Shaderin SwiftUI (iOS 17+)? It allows applying visual effects written in Metal (MSL) directly to views using modifiers like.colorEffector.distortionEffect. - What is the
.drawingGroup()modifier? It flattens the view hierarchy into a single image rendered by Metal. It is used to solve performance issues in complex lists or heavy graphics. - What is
Anchor<T>? An opaque type that stores geometric information of a view to be used by another view in the hierarchy (usually withpreferences). - How does
matchedGeometryEffectwork if you have two views with the same ID on screen? It is undefined behavior and will cause visual glitches. IDs must be unique per active animation group. - What is the
Layoutprotocol (iOS 16)? It allows creating custom containers (like your own Grid or Flow Layout) by defining how to measure and place subviews. - Difference between
PathandShape?Shapeis a View that adjusts to a space.Pathis the mathematical description of a line/curve that can be used inside a Shape. - How do you apply a gradient to text? Using
.foregroundStyle(Gradient...)(iOS 15+). - What is
VisualEffectViewin SwiftUI? It doesn’t exist directly;Materialis used (e.g.,.background(.ultraThinMaterial)).
⚡ Level 10: Concurrency and Lifecycle (Swift 5.5+)
- Why use
.taskinstead of.onAppear?.tasksupports async/await natively and is automatically canceled if the view is destroyed before the task finishes. - What does
@MainActormean in a ViewModel? It guarantees that all properties and methods of that class are accessed/executed on the main thread, preventing UI update errors from background threads. - What happens if you modify a
@Publishedproperty from a background thread? SwiftUI will throw a runtime warning (purple warning) and it could cause crashes or strange UI behavior. - What is
Sendableand how does it affect SwiftUI? It is a protocol indicating that it is safe to pass data between threads. Data passed to views (especially in.taskclosures) should be Sendable. - How do you handle a Data Race in SwiftUI? Using actors (
actor), isolation with@MainActor, and avoiding unprotected mutable shared state. - Does the
bodyof a view execute on the Main Thread? Yes, always. - How do you stop an ongoing task when the user navigates back? If you use
.task, it’s automatic. If you use a manualTask { }inonAppear, you must save the reference and call.cancel()inonDisappear. - What is
AsyncSequencein the context of SwiftUI? It allows iterating over asynchronous data streams (like notifications or download bytes) updating the UI step-by-step. - Can you use
awaitinside a button? Not directly in the button’s closure. You must wrap the call inTask { await ... }. - What is
ViewInspector? It is not native, but it is the de facto standard open-source library for performing Unit Tests on the SwiftUI view hierarchy.
📱 Level 11: Ecosystem (Widgets, WatchOS, Live Activities)
- Which framework is used to create Home Screen Widgets? WidgetKit, which uses SwiftUI exclusively.
- What is a
TimelineEntryin WidgetKit? An object representing the state of the widget at a specific point in time. - Why are animations limited in Widgets? Because widgets are serialized “snapshots”, not live views running constantly (although iOS 17 improved this).
- What is a Live Activity? An interactive and persistent notification on the Lock Screen (and Dynamic Island) for real-time events (e.g., food delivery).
- What is
DynamicIsland? The SwiftUI API to define how your Live Activity looks on the “island” of the iPhone 14 Pro/15. - In watchOS, what replaces
NavigationVieworNavigationStackfor the base hierarchy? GenerallyNavigationStackis used as well, but the pagination style (.tabViewStyle(.verticalPage)) is very common. - What is
.digitalCrownRotation? A watchOS-exclusive modifier to read the value of the digital crown. - How do you share UI code between an iOS App and a Widget? Extracting views to a local package (Swift Package) or including them in both Targets.
- What are App Clips? A small part of your app (under 10-15MB) that runs instantly without full installation. Built with SwiftUI.
- What is
WidgetURL? A modifier that defines which URL opens in the main app when the user taps the widget.
🧩 Level 12: Advanced Data Architecture
- What is
Preferencein SwiftUI? A communication channel from children to parents. Children send data, the parent collects and reduces it. - What is
AnchorPreference? It allows passing bounds and coordinates from a child view to a parent (useful for tooltips or guided highlights). - How do you inject dependencies into a custom
Environment? Creating a customEnvironmentKeyand extendingEnvironmentValues. - What problem does
AnyViewsolve and why should you avoid it? It allows type erasure of a view to return different types in anif/else. It should be avoided because it destroys SwiftUI’s “diffing” optimization, reducing performance. - Instead of
AnyView, what should you use?@ViewBuilderorGroup. - What is the “Coordinator” pattern in SwiftUI? An external class responsible for navigation logic, separating the view from the decision of “where to go”.
- Is it possible to use Redux in SwiftUI? Yes, it is very compatible. You usually have a global
Storeas anObservableObjectand pureReducers. - What is the difference between
@StateObjectand a static global variable?@StateObjectis tied to the view’s lifecycle (released if the view dies). The global variable lives forever (potential memory leak). - How do you force a view update manually (though not recommended)? Using
objectWillChange.send()on an ObservableObject. - How do you detect when the app goes to the background? Using
.onChange(of: scenePhase).
🛠 Level 13: Debugging and Performance (Troubleshooting)
- Why is my view constantly redrawing (infinite loop)? You are probably modifying a
@Stateinside thebodyor in a constructor, which triggers a new render, which modifies the state again. - How do you identify which view is causing slowness? Using “SwiftUI View Hierarchy” in Instruments or the “Color Blended Layers” option in the simulator.
- Why does
Listperform poorly with thousands of complex items? SometimesListdoes not recycle cells as efficiently asUICollectionView. It is suggested to simplify the cell or useLazyVStackinside a ScrollView ifListfails. - What does the error “Modifying state during view update, this will cause undefined behavior” mean? That you are changing data while SwiftUI is calculating the layout (e.g., inside a
GeometryReaderupdating a parent@Statedirectly). - How do you fix the error above? Wrapping the state change in
DispatchQueue.main.asyncor using.onAppear/.task. - What impact does using
.shadow()have on performance? High. Shadows require off-screen rendering. Better to use pre-rendered images or simulated shadows if possible. - What is the “Opaque Return Type” and how does it affect compilation? (
some View). It helps the compiler work faster by not having to infer the entire chain of nested generic types. - Why does my
@Publishednot update the view? Maybe the view is not observing the object with@ObservedObjector@StateObject, or the update happens in a nested property of a class (classes are reference types and@Publisheddoes not observe deep changes automatically).
🧪 Level 14: Swift Charts, MapKit, and New APIs
- How do you create a simple bar chart? Using the
Chartsframework and theChart { BarMark(...) }view. - What is
Plottable? The protocol that data must conform to in order to be represented in Swift Charts (Strings, Ints, Dates, etc.). - How do you show the native map in SwiftUI (iOS 17)? Using the
Map()view. It no longer requires mandatory region binding in newer versions. - What is
MapAnnotationvsMarker?Markeris the standard pin (balloon) with better performance.MapAnnotationallows using a fully custom SwiftUI view as a pin. - What is
ShareLink? The native view to present the system Share Sheet. - How do you implement “Search” in a list? Using the
.searchable(text: $text)modifier. - What is
contentTransition? Defines how the content of a view changes (e.g., numbers spinning like a counter) using.contentTransition(.numericText()).
🔥 Level 15: Trick Questions / Code Scenarios
The interviewer shows you code and asks: “What happens here?”
- Scenario: You have a
VStackwithSpacing: 0and two rectangles of height 50. Is the total height 100? Answer: Not necessarily. The Safe Area or the parent container could compress them if there is no space. - Scenario: You use
@Statefor a class object (class User). Does it work? Answer: It works, but the view will not update when properties insideUserchange, because@Stateonly observes the change of the class pointer, not its contents. - Scenario: You have a
NavigationLinkinside aListbut it doesn’t work when tapped. Answer: Often happens if you have aButtoninside the row that captures the touch, or if you forgot the parentNavigationStack. - Scenario:
Text("Hello").padding().background(Color.red).padding()vsText("Hello").padding().padding().background(Color.red).Answer: In the first one, red surrounds the text with one margin. In the second, red surrounds the text with double margin (the red block looks bigger, or further from the text depending on visual interpretation). Order matters. - Scenario: Why does a
LazyVGridinside a horizontalScrollViewlook bad? Answer: BecauseLazyVGridgrows vertically. You should useLazyHGridinside a horizontal Scroll. - Scenario: You try to apply
.frameto an image, but it doesn’t resize. Answer: You forgot.resizable()before the frame. - Scenario: Can a
@Bindingbe optional (Binding<Bool?>)? Answer: Yes, it is possible. - Scenario: What happens if you call an impure function in
body? Answer: It will execute multiple times unpredictably, causing side effects (bugs). - Scenario: How do you hide the navigation bar? Answer:
.toolbar(.hidden)or.navigationBarHidden(true)(deprecated). - Scenario: You have a
ForEachwith a range0..<items.count. Is it safe? Answer: It is dangerous. If the array changes size, it will cause an “Index out of range” crash. Always useForEach(items)withIdentifiable.
🏆 Level 16: The Master Touch (Miscellaneous)
- What is
FocusState? Controls which text field has keyboard focus. - What is
SubmitLabel? Changes the keyboard “Enter” button (e.g., to “Search”, “Go”, “Next”). - How do you detect screenshots? Listening for the
userDidTakeScreenshotNotificationinonReceive. - How do you add a context menu (long press)? With the
.contextMenumodifier. - What is
Menuin SwiftUI? A button that displays a list of options when tapped (does not require long press). - How do you use custom fonts? Adding the file to Info.plist and using
.font(.custom("Name", size: 12)). - What is
Label? A view that combines an icon and text automatically aligned. - How do you force Light Mode on a specific view?
.preferredColorScheme(.light). - What is
Stepper? A control to increment/decrement a numeric value. - What is
DisclosureGroup? A collapsible view (accordion) that shows or hides content. - How do you do “Swipe Actions” in a list? Using the
.swipeActionsmodifier on the cell. - What is
OutlineGroup? To show hierarchical data structures (trees) in an expandable list. - How do you align text to the left in a VStack?
VStack(alignment: .leading). - Why doesn’t
Spacer()work in aZStack? BecauseZStackoverlays elements, it doesn’t distribute them along an axis. - What is
EmptyView? A view that occupies no space and renders nothing. Useful as a default return in@ViewBuilder. - What is
Divider? A thin visual line (horizontal or vertical depending on the stack) to separate content. - How do you detect device orientation? Using
GeometryReaderand comparing width vs height, or listening to changes inUIDevice. - What is
ScaledMetric? A property wrapper that scales a numeric value (like an icon size) proportionally to the user’s text size settings. - Can you use
CoreDatawithoutNSPersistentCloudKitContainerin SwiftUI? Yes, but you lose automatic iCloud synchronization. - If you had to define SwiftUI in one sentence to convince a manager, what would you say? “SwiftUI reduces UI code by 60%, eliminates entire categories of state bugs, and drastically speeds up design iteration thanks to its declarative nature and real-time previews.”