Reading time: 1 min
This recipe shows how to implement sticky headers & footers when using a LazyVStack or LazyHStack instead of a List
.
SwiftUI Drag To Reorder ForEach / Stack / Grid
Reading time: 3 min
This recipe shows how to implement drag & drop to reorder items in SwiftUI. It offers a recipe for a generic ReorderableForEach which can then be plugged into any layout, such as VStack
, LazyVGrid
, etc.
SwiftUI Max Width Buttons in VStack
Reading time: 1 min
This recipe shows how to make all items in a VStack take up the same width as the widest item.
SwiftUI Orientation Stack
Reading time: 1 min
This recipe shows how to implement an orientation stack in SwiftUI. This stack will lay out its content along the main screen axis - vertical or horizontal. In other words, it's a VStack
if your phone is in portrait mode and an HStack
if it's in landscape.
Weighted Layout (HStack and VStack) in SwiftUI
Reading time: 3 min
This recipe shows how to add weights to HStack and VStack elements, so that you can easily size them relative to each other. E.g, if you had two views, one with weight of 10, and the other with weight of 5, the first one would be twice as wide / tall as the second one.