Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying SwiftUI Cookbook
  • Table Of Contents Toc
SwiftUI Cookbook

SwiftUI Cookbook - Second Edition

By : Giordano Scalzo, Edgar Nzokwe
4.3 (20)
close
close
SwiftUI Cookbook

SwiftUI Cookbook

4.3 (20)
By: Giordano Scalzo, Edgar Nzokwe

Overview of this book

SwiftUI provides an innovative and simple way to build beautiful user interfaces (UIs) for all Apple platforms, from iOS and macOS through to watchOS and tvOS, using the Swift programming language. In this recipe-based cookbook, you’ll cover the foundations of SwiftUI as well as the new SwiftUI 3 features introduced in iOS 15 and explore a range of essential techniques and concepts that will help you through the development process. The cookbook begins by explaining how to use basic SwiftUI components. Once you’ve learned the core concepts of UI development, such as Views, Controls, Lists, and ScrollViews, using practical implementations in Swift, you'll advance to adding useful features to SwiftUI using drawings, built-in shapes, animations, and transitions. You’ll understand how to integrate SwiftUI with exciting new components in the Apple development ecosystem, such as Combine for managing events and Core Data for managing app data. Finally, you’ll write iOS, macOS, and watchOS apps by sharing the same SwiftUI codebase. By the end of this SwiftUI book, you'll have discovered a range of simple, direct solutions to common problems encountered when building SwiftUI apps.
Table of Contents (17 chapters)
close
close

Using LazyHStack and LazyVStack

SwiftUI 2.0 introduced the LazyHStack and LazyVStack views. They can be used similar to the regular HStack and VStack views (discussed in Chapter 1, Using the Basic SwiftUI Views and Controls) but offer an extra advantage of lazy loading its content. The list's content is loaded just before it becomes visible on the device's screen, allowing the user to seamlessly scroll through large datasets with no perceptible UI lag or long load times. Let's create an app to see how this works in practice.

Getting ready

Create a new SwiftUI app called LazyStacks.

How to do it…

We will create an app that applies both the LazyHStack and LazyVStack views. We will ensure that each list row prints out some text to the console before being loaded. That way, we'll know what is being loaded and when. The steps are as follows:

  1. Create a ListRow view that has two properties: an id and a type. The ListRow view will print out some...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
SwiftUI Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon