filmov
tv
Using Lazy Stacks - Creating a Dynamic View Layout with SwiftUI - raywenderlich.com
![preview_player](https://i.ytimg.com/vi/BD9vzG0qUXc/sddefault.jpg)
Показать описание
The first of SwiftUI's "lazy" views that we'll be going over are the Stacks. LazyVStacks and LazyHStacks are typically used within ScrollViews.
View the episode here:
About the course:
This course is part of our iOS User Interfaces with SwiftUI learning path. You're ready for this course if you're working through that learning path in order, or you're someone who has a bit of iOS and Swift experience: enough to know the basics of putting views onscreen in a SwiftUI-based app.
The first part of the course is all-new for iOS 14. You'll be working a lot with scroll views, and lazy views: both stacks, and grids.
In the second part, you'll start working with Alignments, which are key to making the most out of Stacks. You'll learn how to use built-in alignment guides, and create your own custom ones. The course will conclude with the ZStack and GeometryReader structures.
Throughout the course, you'll practice everything you learn with hands-on challenges, recreating the kind of layouts you'll find in user interfaces from popular iOS apps.
This course isn’t suited for advanced developers. If that’s you, check out our advanced video courses for more ways to level-up your developer skills!
--
---
About SwiftUI: (from Apple)
SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With a declarative Swift syntax that’s easy to read and natural to write, SwiftUI works seamlessly with new Xcode design tools to keep your code and design perfectly in sync. Automatic support for Dynamic Type, Dark Mode, localization, and accessibility means your first line of SwiftUI code is already the most powerful UI code you’ve ever written.
Declarative Syntax
SwiftUI uses a declarative syntax so you can simply state what your user interface should do. For example, you can write that you want a list of items consisting of text fields, then describe alignment, font, and color for each field. Your code is simpler and easier to read than ever before, saving you time and maintenance.
Drag and drop. Arrange components within your user interface by simply dragging controls on the canvas. Click to open an inspector to select font, color, alignment, and other design options, and easily re-arrange controls with your cursor. Many of these visual editors are also available within the code editor, so you can use inspectors to discover new modifiers for each control, even if you prefer hand-coding parts of your interface. You can also drag controls from your library and drop them on the design canvas or directly on the code.
Dynamic replacement. The Swift compiler and runtime are fully embedded throughout Xcode, so your app is constantly being built and run. The design canvas you see isn’t just an approximation of your user interface — it’s your live app. And Xcode can swap edited code directly in your live app with “dynamic replacement”, a new feature in Swift.
Previews. You can now create one or many previews of any SwiftUI views to get sample data, and configure almost anything your users might see, such as large fonts, localizations, or Dark Mode. Previews can also display your UI in any device and any orientation.
Native on All Apple Platforms
SwiftUI was built on decades of experience in creating the most innovative and intuitive user interfaces in the world. Everything users love about Apple ecosystems, such as controls and platform-specific experiences, is beautifully presented in your code. SwiftUI is truly native, so your apps directly access the proven technologies of each platform with a small amount of code and an interactive design canvas.
View the episode here:
About the course:
This course is part of our iOS User Interfaces with SwiftUI learning path. You're ready for this course if you're working through that learning path in order, or you're someone who has a bit of iOS and Swift experience: enough to know the basics of putting views onscreen in a SwiftUI-based app.
The first part of the course is all-new for iOS 14. You'll be working a lot with scroll views, and lazy views: both stacks, and grids.
In the second part, you'll start working with Alignments, which are key to making the most out of Stacks. You'll learn how to use built-in alignment guides, and create your own custom ones. The course will conclude with the ZStack and GeometryReader structures.
Throughout the course, you'll practice everything you learn with hands-on challenges, recreating the kind of layouts you'll find in user interfaces from popular iOS apps.
This course isn’t suited for advanced developers. If that’s you, check out our advanced video courses for more ways to level-up your developer skills!
--
---
About SwiftUI: (from Apple)
SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With a declarative Swift syntax that’s easy to read and natural to write, SwiftUI works seamlessly with new Xcode design tools to keep your code and design perfectly in sync. Automatic support for Dynamic Type, Dark Mode, localization, and accessibility means your first line of SwiftUI code is already the most powerful UI code you’ve ever written.
Declarative Syntax
SwiftUI uses a declarative syntax so you can simply state what your user interface should do. For example, you can write that you want a list of items consisting of text fields, then describe alignment, font, and color for each field. Your code is simpler and easier to read than ever before, saving you time and maintenance.
Drag and drop. Arrange components within your user interface by simply dragging controls on the canvas. Click to open an inspector to select font, color, alignment, and other design options, and easily re-arrange controls with your cursor. Many of these visual editors are also available within the code editor, so you can use inspectors to discover new modifiers for each control, even if you prefer hand-coding parts of your interface. You can also drag controls from your library and drop them on the design canvas or directly on the code.
Dynamic replacement. The Swift compiler and runtime are fully embedded throughout Xcode, so your app is constantly being built and run. The design canvas you see isn’t just an approximation of your user interface — it’s your live app. And Xcode can swap edited code directly in your live app with “dynamic replacement”, a new feature in Swift.
Previews. You can now create one or many previews of any SwiftUI views to get sample data, and configure almost anything your users might see, such as large fonts, localizations, or Dark Mode. Previews can also display your UI in any device and any orientation.
Native on All Apple Platforms
SwiftUI was built on decades of experience in creating the most innovative and intuitive user interfaces in the world. Everything users love about Apple ecosystems, such as controls and platform-specific experiences, is beautifully presented in your code. SwiftUI is truly native, so your apps directly access the proven technologies of each platform with a small amount of code and an interactive design canvas.