-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day05-Grid.swift
57 lines (47 loc) · 1.72 KB
/
Day05-Grid.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//: A UIKit based Playground for presenting user interface
import SwiftUI
import PlaygroundSupport
struct ContentView : View {
private var columns: [GridItem] = [
GridItem(.fixed(50), spacing: 10),
GridItem(.fixed(200), spacing: 10),
// GridItem(.fixed(50), spacing: 50)
// GridItem(.adaptive(minimum: 10), spacing: 16),
// GridItem(.adaptive(minimum: 20, maximum: 50), spacing: 16),
// GridItem(.adaptive(minimum: 10), spacing: 16)
]
var body: some View {
ScrollView{
VStack {
LazyVGrid(
columns: columns,
alignment: .center,
spacing: 16,
pinnedViews: [] //[.sectionHeaders, .sectionFooters]
) {
Section(header: Text("Section 1 ").font(.title)) {
ForEach(0...10, id: \.self) { index in
let randomColor: Color = .random
randomColor
}
}
Section(header: Text("Section 2").font(.title)) {
ForEach(11...35, id:\.self) { index in
let randomColor: Color = .random
randomColor
}
}
}
}
}
}
}
extension Color {
static var random: Color {
return Color(red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1))
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.setLiveView(ContentView())