How to Change the Background Color of a View in SwiftUI
Learn different ways to set background colors on SwiftUI views, from simple color fills to gradients and materials.
// Build a strong foundation in SwiftUI. Learn about views, modifiers, layout containers, alignment, and essential SwiftUI patterns.
Learn different ways to set background colors on SwiftUI views, from simple color fills to gradients and materials.
Learn what the "some" keyword means in Swift, how opaque return types work, and why SwiftUI uses "some View" everywhere.
NavigationStack replaced NavigationView in iOS 16 with a more powerful programmatic navigation model. Here's what changed and how to migrate.
Learn how to access photos from the camera roll in SwiftUI, including required permissions, Info.plist configuration, and using PhotosPicker for iOS 16+ or UIImagePickerController for earlier versions.
Learn how to detect when a user successfully shares content using a share sheet in SwiftUI by wrapping UIActivityViewController.
Make your glass elements respond to touch with scaling, shimmer effects, and touch-point illumination using the interactive() modifier and glass button styles.
The glassEffectID modifier enables glass views to smoothly morph into one another during state changes, creating fluid transitions that feel native to iOS 26.
Learn how to use the allowsHitTesting modifier to make views ignore touches, letting taps pass through to elements behind them.
iOS 26 introduces Liquid Glass, a translucent design language for navigation elements. Here's how to apply the glassEffect modifier to your custom views.
Learn how to round only certain corners of a SwiftUI view using UnevenRoundedRectangle, custom shapes, and clipShape.
Learn how to resize images in SwiftUI using resizable(), frame(), and different content modes like scaledToFit and scaledToFill.
Learn how to show loading spinners in SwiftUI using ProgressView, including customization options and common loading patterns.
Learn how to detect when users shake their device in SwiftUI by bridging to UIKit's motion events and creating a reusable view modifier.
Understand the difference between @State and @Binding in SwiftUI, when to use each, and how they work together to manage data flow between views.
Learn how to use ToolbarSpacer to add fixed and flexible spacing between toolbar items in SwiftUI, new in iOS 26.
Failable initializers offer a cleaner alternative to if-let statements when your SwiftUI views depend on optional data.
Learn how to use the presentationDetents modifier to control sheet heights in SwiftUI, creating interactive bottom sheets similar to Apple Maps and Music.
When SwiftUI previews fail with cryptic errors or just spin forever, here's how to diagnose and fix the most common causes.
Learn how to use the contentShape modifier to expand or customize the tappable area of your SwiftUI views, making buttons and interactive elements more user-friendly.
Safe areas keep your content visible and interactive. Here's how they work in SwiftUI and when you should ignore them.
When building UIs that stream AI-generated content using Apple's Foundation Models framework, testing intermediate states in Xcode Previews requires some creative workarounds. Here's how to preview partially generated content without calling the actual model.
Understanding the difference between frame alignment and stack alignment is the key to centering views exactly where you want them in SwiftUI.
Learn how to add horizontal padding inside a TextEditor without affecting the scrollbar using the contentMargins modifier introduced in iOS 17.
Learn how to access SwiftUI environment values in View extensions using ViewModifiers for clean, reusable code.
Learn how to create and display QR codes in SwiftUI using Core Image filters.
Learn how to create a Material Design-style floating action button in SwiftUI that intelligently moves above the keyboard and avoids blocking text input fields.
How to detect when users scroll to the bottom of a list and automatically load more content.
Learn how to add custom toolbar buttons above the keyboard in SwiftUI using the .toolbar modifier with keyboard placement for Done buttons, formatting controls, and more.
Learn how to prevent users from taking screenshots of sensitive content in your SwiftUI app using field-level security and UIKit bridging for financial, medical, or private data protection.
Learn how to create a custom input accessory view that stays above the keyboard, similar to iMessage's input bar.
Learn how to add pull-to-refresh functionality to custom ScrollViews in SwiftUI without using List, perfect for custom layouts and complex scroll content.
Learn how to build skeleton loading screens with animated shimmer effects in SwiftUI using gradients, AnimatableModifier, and reusable view modifiers for a polished loading experience.
Learn how to implement undo/redo functionality in SwiftUI using UndoManager, including environment injection, registering actions, and creating undo buttons for professional editing experiences.
Learn how to align single and multiline text in SwiftUI.
Learn how to use ScrollViewReader and ScrollViewProxy to scroll a SwiftUI list to a specific item automatically.
Learn how to detect when a context menu is open in SwiftUI.
Learn how to create a WebView/WKWebView with a transparent/clear background in SwiftUI.
Learn how to accept user input in an alert using TextField or SecureField.
Learn how to create a modifier that limits the characters that can be entered in a TextEditor or TextField view in SwiftUI.
Learn the ways to scale a text view's font size to fit its parent view in SwiftUI.
Learn how to use a WKWebView as a quick way to load a GIF from a URL and display it in a SwiftUI view.
Learn how to use DisclosureGroupStyle to create custom DisclosureGroup views in SwiftUI.
Learn how to detect if a SwiftUI app is running in a Xcode Preview.
How to use the SwiftUI DisclosureGroup view to create collapsable content.
Learn how to access your app's App Delegate from anywhere in your Swift code, including from SwiftUI views.