ModeChanger is a small SwiftUI sample app that demonstrates how to let a user choose the app's appearance mode and persist that choice across launches.
The app supports three appearance options:
- System
- Light
- Dark
The selected mode is stored with @AppStorage and applied at the app entry point with preferredColorScheme.
- Xcode 26.4 or later
- iOS 26.4 or later
- Open
ModeChanger.xcodeprojin Xcode. - Select an iOS simulator or device.
- Build and run the
ModeChangerscheme.
ModeChangerApp.swift- App entry point that applies the saved appearance mode.ContentView.swift- Main screen with navigation, modal presentation, and the appearance picker.AppearanceMode.swift- Enum that defines the supported appearance modes, labels, icons, and color schemes.NavigationStackView.swift- Example pushed view.ModalSheetView.swift- Example modal sheet.
The appearance menu is shown in the bottom toolbar. Selecting a mode updates the app immediately and saves the preference for the next launch.
