SwiftUI
Learn more and get better in building apps with SwiftUI.
Accessibility in SwiftUI explained for UIKit developers
Adding accessibility support in SwiftUI will be more approachable for you compared to UIKit. But still, if you’ve been sharpening your UIKit skills for years, it takes a while to get your head around the new declarative/reactive way of doing things. It is an entirely different mental model, and it ...
VoiceOver navigation improvement tips for SwiftUI apps
VoiceOver navigation support in your apps comes with the same requirements as navigating through touch controls. When navigating apps with standard touch controls, we tend to dislike apps that feel cluttered or make us do many interactions to achieve something. We'd probably say such an app does not offer a ...
@ViewBuilder usage explained with code examples
The @ViewBuilder attribute is one of the few result builders available for you to use in SwiftUI. You typically use it to create child views for a specific SwiftUI view in a readable way without having to use any return keywords. I encourage you to read my article Result builders ...
UIViewRepresentable explained to host UIView instances in SwiftUI
Adopting the UIViewRepresentable protocol allows you to host UIView instances in SwiftUI. Your SwiftUI code is converted to UIKit views behind the scenes. SwiftUI requires you to declare the view representation, but the underlying SwiftUI implementation will optimize how final views are drawn on the screen. You can use a ...
Using NavigationLink programmatically based on binding in SwiftUI
NavigationLink in SwiftUI allows pushing a new destination view on a navigation controller. You can use NavigationLink in a list or decide to push a view programmatically. The latter enables you to trigger a new screen from a different location in your view. Allowing to push a new screen onto ...
Markdown rendering using Text in SwiftUI
SwiftUI comes with built-in markdown support for text, making it easy to transform the text into bold, italic, and other formats. iOS 15 and SwiftUI 3 introduced support taking away the need to combine text weight for similar results. Markdown isn't wholly supported (more on that later), but many features ...
Downloading and Caching images in SwiftUI
Downloading and caching images is an essential part of building apps in Swift. There are several ways of downloading images with 1st party APIs 3rd party libraries. In my experience, every developer has their way of handling remote images since there's no go-to standard. SwiftUI introduced AsyncImage as a 1st ...
Disable animations on a specific view in SwiftUI using transactions
Animations in SwiftUI look great and make your app shine, but sometimes you want to disable animations on a specific view since it doesn't look great when animating. Compared to UIKit, SwiftUI makes it easier to create animated transitions between two states using the animation view modifier. You can see ...
Error alert presenting in SwiftUI simplified
Presenting error alerts in apps is essential to communicate failures to your end-users. The happy flow of apps is often implemented well, but the unhappy flow is equally important. Managing all kinds of error alerts can be frustrating if you have to present them all individually. While building my apps, ...
@Published risks and usage explained with code examples
@Published is one of the property wrappers in SwiftUI that allows us to trigger a view redraw whenever changes occur. You can use the wrapper combined with the ObservableObject protocol, but you can also use it within regular classes. It's essential to understand how the published property wrapper works since ...
@StateObject vs. @ObservedObject: The differences explained
The @StateObject and @ObservedObject property wrappers tell a SwiftUI view to update in response to changes from an observed object. Both wrappers look similar but have an essential distinction to be aware of when building apps in SwiftUI. At first, you might wonder why you wouldn't just always use @ObservedObject ...
How to use the Redacted View Modifier in SwiftUI with useful extensions
The redacted view modifier in SwiftUI allows us to create a so-called skeleton view while our data is loading. Using a skeleton view instead of a spinner lets the user get a sense of how our views will look once the data is loaded. The user experience is smoother and ...