SwiftUI TabView Styling (All iOS Versions)
Reading time: 2 min
This recipe shows how to style a TabView
in SwiftUI - change its background color, text and icon colors and styles, as well as changing the badge coloring. This solution works on all SwiftUI and iOS versions. The end result looks like this:
The recipe goes as follows:
- Set icon, text and...
Reading time: 11 min
Here you can find recipes for common tasks you need when working with the new Swift 5.5 concurrency model.
Where applicable, there's before and after comparison that shows how things where done before async/await (mostly with GCD) and how they can be done now.
This list will be updated as S...
Navigate Fields Using Keyboard in SwiftUI
Reading time: 1 min
This recipe shows how to navigate from one text field to another using keyboard buttons in SwiftUI by combining @FocusState
and onSubmit
. The end result looks like this:
The recipe goes as following:
- Declare an enum that holds aliases for focusable fields. In the code below, that's
Form...
Keyboard Toolbar in SwiftUI
Reading time: 1 min
This recipe shows how to add a toolbar with action buttons on the top of soft keyboard in SwiftUI. The end result looks like this:
This feature is available starting with SwiftUI 3 (iOS 15, macOS 12).
The pattern for adding the toolbar to the keyboard is the same as with toolbar setups,...
Reading time: 6 min
Pull to refresh is a common UI pattern, supported in UIKit
via UIRefreshControl
. (Un)surprisingly, it's also unavailable in SwiftUI. (EDIT: It's been added in SwiftUI 3 - however, it has many drawbacks compared to this solution.)
This recipe shows how to implement this functionality w...