Switching Layout Using SwiftUI AnyLayout
Starting from iOS 16, SwiftUI provides AnyLayout and the Layout protocol for developers to create customized and complex layouts. AnyLayout is a type-erased instance of the layout protocol. You can use AnyLayout to create a...
Mastering SwiftUI for iOS 16 and Xcode 14 is Now Released
As you know, Apple released Xcode 14 and iOS 16, along with the debut of iPhone 14. Now our Mastering SwiftUI book is updated to support the latest version of iOS and Xcode. All the content including screenshots and...
How to Use SwiftUI Gauge and Create Custom Gauge Styles in iOS 16
In iOS 16, SwiftUI introduces a new view called Gauge for displaying progress. You can actually use it to show values within a range. In this tutorial, let’s see how to use the Gauge view and work with different gauge...
A Beginner’s Guide to NavigationSplitView in SwiftUI for iOS 16
In iOS 16, other than introducing the new NavigationStack, Apple also released a new view container named NavigationSplitView for developers to create two or three column navigation interface. If you want to build UI similar to...
How to Use PhotosPicker in SwiftUI
Prior to iOS 16, if you need to display a photo picker for users to choose photos from Photo library, you have to rely on PHPickerViewController or the older UIImagePickerController of UIKit. It’s not difficult to use it as...
SwiftUI ImageRenderer: How to Create PDF Documents
Earlier, we showed you how to use ImageRenderer to capture a SwiftUI view and save it as an image. This new class, introduced in iOS 16, can also let you convert a view into a PDF document. In this tutorial, we will build on the...
Using ImageRenderer to Convert SwiftUI Views into Images
ImageRenderer is another new API for SwiftUI that comes with iOS 16. It allows you to easily convert any SwiftUI views into an image. The implementation is very simple. You instantiate an instance of ImageRenderer with a view for...
How to Use ShareLink for Sharing Data Like Text and Photos
In iOS 16, SwiftUI comes with a new view called ShareLink. When users tap on the share link, it presents a share sheet for users to share content to other applications or copy the data for later use. The ShareLink view is...
Optional Binding in Swift 5.7: A Shorter Version of if let
Other than all the new features of SwiftUI in iOS 16, Apple also announced Swift 5.7 which will come along with the release of Xcode 14. Let’s check out one minor but welcome change in Swift 5.7. Swift has the concept of...
Creating a Line Chart Using SwiftUI Charts API
The Charts framework is one of my favourite features for the new version of SwiftUI in iOS 16. Prior to iOS 16, you need to build your own charts or rely on third party library to render charts for you. With the release of this...