A lightweight, hand-built alert overlay in SwiftUI with a blurred backdrop and spring animation.
Custom Alert View is a small SwiftUI sample that demonstrates how to build a custom alert card from scratch instead of relying on the system .alert modifier. A toolbar button toggles a rounded alert card that appears over a scrolling list, while the underlying content is blurred to keep focus on the alert. The whole transition is driven by a single spring .animation, and a circular close button dismisses it.
- Custom alert card overlaid on top of the main content using a
ZStack, rather than the built-in system alert. - Spring-animated show/hide transition bound to a single
@Stateflag. - Background list blurs (
blur(radius:)) while the alert is presented to draw focus. - Circular red close button plus a toolbar toggle that switches between "Open" and "Close".
- Reusable styling factored into
Viewextension modifiers (alertModifiers,closeButtonModifiers,ListViewModifiers). - Centralized UI strings and SF Symbol names in a
Constantsenum.
git clone https://github.com/ahmetbostanciklioglu/CustomAlertViewSwiftUI.git
cd CustomAlertViewSwiftUI
open CustomAlertViewSwiftUI.xcodeprojOnce the project opens in Xcode, select an iOS Simulator (or a connected device) and press Command + R to build and run.
- Xcode 26 or later
- iOS 15.6+ deployment target
- Swift 5.0
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!


