SwiftUI 中类 Pinterest 的布局
MasonryStack
SwiftUI 的 Pinterest 排版(水平和垂直)。
Screen.Recording.2023-08-25.at.19.14.28.mov
用法
MasonryHStack
和 MasonryVStack
可以像 HStack
或 VStack
一样使用:
import SwiftUI
import MasonryStack
struct ContentView: View {
var body: some View {
MasonryVStack(columns: 2, spacing: 20) {
// ...
}
}
}
这两个堆栈都遵循 Layout
协议,因此您也可以在其他布局之间轻松切换。