Search bar in SwiftUI (Updated 08/21)
Reading time: 2 min
This tutorial shows you how to create a search bar in SwiftUI. There are two ways of doing it:
- Create a custom view, which works on any SwiftUI Version.
- Use the
searchable
modifier, introduced in Swift 3.
Custom Search Bar View
The end result will look something like this:
The s...
SwiftUI Image Picker
Reading time: 1 min
This recipe shows how to add an image picker to your SwiftUI app. You'll do this by wrapping a UIKit UIImagePickerController
in a UIViewControllerRepresentable
. The end result looks like this:
This recipe is a part of our Road to DigitalSignatureView series, which explores various co...
Detect App Moving to Background in SwiftUI
Reading time: 1 min
This recipe shows two ways of detecting when your app goes to foreground or background.
NotificationCenter solution
The first solution works on iOS 13+ and any device, iPhone or iPad, and is generally the one you should use. First, add these two extensions to your app:
extension View {
f...
GIF Images in SwiftUI
Reading time: 4 min
This recipe shows how to render GIFs in SwiftUI. The end result looks like this:
This component is available as a Swift package in this repo.
GIFs are a weird animal in the iOS/macOS world - while CoreGraphics contain ways of extracting GIF-related info from raw data, there's no na...
WebView in SwiftUI
Reading time: 4 min
This recipe shows how to embed a WKWebView
into SwiftUI and have a (somewhat) functional browser in your app! The end result looks like this:
This component is available as a Swift package in this repo.
Modelling the behaviour
WKWebView
is a powerful and intricate component that d...