Book Image

An iOS Developer's Guide to SwiftUI

By : Michele Fadda
Book Image

An iOS Developer's Guide to SwiftUI

By: Michele Fadda

Overview of this book

– SwiftUI transforms Apple Platform app development with intuitive Swift code for seamless UI design. – Explore SwiftUI's declarative programming: define what the app should look like and do, while the OS handles the heavy lifting. – Hands-on approach covers SwiftUI fundamentals and often-omitted parts in introductory guides. – Progress from creating views and modifiers to intricate, responsive UIs and advanced techniques for complex apps. – Focus on new features in asynchronous programming and architecture patterns for efficient, modern app design. – Learn UIKit and SwiftUI integration, plus how to run tests for SwiftUI applications. – Gain confidence to harness SwiftUI's full potential for building professional-grade apps across Apple devices.
Table of Contents (25 chapters)
Free Chapter
1
Part 1: Simple Views
5
Part 2: Scrollable Views
8
Part 3: SwiftUI Navigation
11
Part 4: Graphics and Animation
14
Part 5: App Architecture
17
Part 6: Beyond Basics

The Art of Displaying Grids

This chapter will discuss how you can create grid structures in your SwiftUI applications.

We won’t cover supporting iOS 13; that would require the old approach with nested stacks. The old approach would have created a grid by using horizontal stacks, each representing a row inside a vertical stack. You could also do the opposite, but this would be less common. As SwiftUI evolved, we can now represent orthogonal grids directly, instead of having to compose them. Grids are among the most important ways to structure content in iOS and are essential in other Apple platforms as well.

In this chapter, we are going to show you how by covering these main topics:

  • Displaying grids in iOS
  • The grid view
  • Lazy grids
  • Using GridItem to control the lazy grid layout
  • Conditional formatting of a view
  • Reacting to device rotation

At the end of this chapter, you will be able to decide whether to use eager or lazy grids, knowing...