Chapter 7
Formatting Your User Interface
IN THIS CHAPTER
Laying out your views
Justifying views
Inserting spacing between views
Animating with ZStack
Displaying views for collecting user inputs
Logically grouping views
In the previous chapters, I show you how the various views in SwiftUI help you to create compelling user interfaces (UIs) in your iOS apps. I also show you a few ways to lay out your views using the VStack
, HStack
, and ZStack
views. In this chapter, I explain these views in more detail and tell you how they allow you to lay out your UI in different ways.
Laying Out Views Using Stacks
In SwiftUI, you describe your app's UI in the view’s body
property:
struct ContentView: View {
var body: some View {
// your UI here
}
}
The body
property only returns a single view, so no matter how complex your UI is, it needs to return only one single view. To create a compelling ...
Get SwiftUI For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.