ScrollView & Stacks
Note: In the demo where you use the frame modifier to affect the layout of the cells, we use a
min calculation with a
+ operator. However, you should use a
max with a
-. This has been added as notes to the project and you'll be notified within the project. The line in question should be written:
.frame(width: max(proxy.size.width - proxy.frame(in: .global).midX,. The culprit seems to cause a crash in the latest version of SwiftUI.
Note: In this episode, you may see the now-obsolete #if DEBUG macro, which used to be utilised for previews to run in the canvas. This is now no longer necessary, and you can safely ignore it. We’ve removed it from the project for convenience as well.
When you want to create more advanced layouts similar to UICollectionViews in SwiftUI, ScrollViews and Stacks are there to help.