ScrollView {
Grid(1...69, id: \.self) { index in
Image("\(index)")
.resizable()
.scaledToFit()
}
}
.gridStyle(
StaggeredGridStyle(.horizontal, tracks: 8, spacing: 4)
)
Tracks
Tracks setting allows you to customize grid behaviour to your specific use-case. Both Modular and Staggered grid use tracks value to calculate layout. In Modular layout both columns and rows are tracks.
public enum Tracks: Hashable {
case count(Int)
case fixed(CGFloat)
case min(CGFloat)
}
Count
Grid is split into equal fractions of size provided by a parent view.
SwiftUI Grid
SwiftUI Grid view layout with custom styles.
Features
Open
GridDemo.xcodeproj
for more examples for iOS, macOS, watchOS and tvOSStyles
ModularGridStyle (Default)
StaggeredGridStyle
Tracks
Tracks setting allows you to customize grid behaviour to your specific use-case. Both Modular and Staggered grid use tracks value to calculate layout. In Modular layout both columns and rows are tracks.
Count
Grid is split into equal fractions of size provided by a parent view.
Fixed
Item size is fixed to a specific width or height.
Min
Autolayout respecting a min item width or height.
Preferences
Get item size and position with preferences
SDKs
Roadmap
Code Contributions
Feel free to contribute via fork/pull request to master branch. If you want to request a feature or report a bug please start a new issue.
Coffee Contributions
If you find this project useful please consider becoming my GitHub sponsor.