Ever since its original introduction in 2019, SwiftUI has had really strong interoperability with UIKit. Both UIView and UIViewController instances can be wrapped to become fully SwiftUI-compatible, and UIHostingController lets us render any SwiftUI view within a UIKit-based view controller. However, even though macOS has had an NSHostingView for inlining SwiftUI views directly within any […]
Chris Eidhof returns to the podcast to talk about how SwiftUI has evolved since its initial release, to share several key learnings from using it over the past few years, and to discuss concepts like app architecture and state management. Judo: Quickly build native, server-driven UI for iOS and Android, and publish instantly, without having […]
A major part of the challenge of architecting UI-focused code bases tends to come down to deciding where to draw the line between the code that needs to interact with the platform’s various UI frameworks, versus code that’s completely within our own app’s domain of logic. That task might become especially tricky when working with […]
SwiftUI offers several different ways for us to create stacks of overlapping views that can be arranged along the Z axis, which in turn enables us to define various kinds of overlays and backgrounds for the views that we build. Let’s explore some of those built-in stacking methods and what sort of UIs that they […]
When building modern applications, it’s incredibly common to want to trigger some form of asynchronous action in response to a UI event. For example, within the following SwiftUI-based PhotoView, we’re using a Task to trigger an asynchronous onLike action whenever the user tapped that view’s button: struct PhotoView: View { var photo: Photo var onLike: […]
Between banking and crypto apps, it’s quite often we interact with currency inputs on daily basis. If creating a localized UITextField can already be tricky in UIKit, I was wondering how hard it would be to do a similar one in SwiftUI. Let’s see today how to create a localized currency TextField in SwiftUI. This […]
To say that SwiftUI’s List is the equivalent of UIKit’s UITableView is both true and false at the same time. It’s definitely true that List offers a built-in way to construct list-based UIs that are rendered using the same overall appearance as when using UITableView — however, when it comes to mutations, we instead have […]
As a general rule of thumb, all of the APIs and system features that Apple introduces in a given version of iOS can only be used when targeting that particular version, or any subsequent ones. However, this year there are a few very interesting exceptions to that rule, in that certain SwiftUI APIs that were […]
By default, the various navigation APIs that SwiftUI provides are very much centered around direct user input — that is, navigation that’s handled by the system in response to events like button taps and tab switching. However, sometimes we might want to take more direct control over how an app’s navigation is performed, and although […]
Starting in Xcode 13, SwiftUI views can now be previewed in landscape orientation using the new previewInterfaceOrientation modifier. For example, here we’re previewing a MenuView in both portrait and landscape by creating two instances of our view within its PreviewProvider: struct MenuView_Previews: PreviewProvider { static var previews: some View { MenuView() MenuView().previewInterfaceOrientation(.landscapeRight) } } Note […]