SwiftUI Async Image tutorial - Learn how to load images asynchronously from the Internet in Xcode

Опубликовано: 28 Сентябрь 2024
на канале: Credo Academy
1,498
35

🟢 LIMITED TIME OFFER - SAVE 37%
Practical iOS and macOS app development tutorials with SwiftUI in 4K
https://credo.academy

In this practical SwiftUI tutorial, we will learn how to load and display an image asynchronously from the Internet. Learn how to use Async Image in SwiftUI 3 framework in Xcode. Note that the SwiftUI #AsyncImage view uses the shared URL Session instance to load an image from a specified URL and then display it on the iPhone's screen.

CHAPTERS

00:00 Introduction
00:59 AsyncImage basics
02:48 AsyncImage scale
04:10 Custom placeholder
06:41 Image extension
08:57 AsyncImage phase
11:42 Testing the AsyncImage phases
12:34 AsyncImagePhase enum
15:51 Animation with AsyncImage
17:16 Testing the application
18:54 Wrap up

Until the remote image loads, the view displays either a standard or a custom-built placeholder.

To gain more control over the loading process, we can use the initializer, which takes a content closure that receives an Async Image Phase to indicate the state of the loading operation.

By doing that, we can control what to display on the screen.

In a nutshell, we can return a view that's appropriate for the current phase, such as success, failure, or empty phase.

Alright!

Without further ado, let's create a new project in Xcode and start coding for iPhone and iPad devices.

This SwiftUI tutorial is part of the best online SwiftUI Masterclass course.

#SwiftUI #Xcode #iOSDevelopment #iPhone