File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
import SwiftUI
2
2
3
3
struct ContentView : View {
4
- @State var width : CGFloat = 300
5
- @State var selectedView : String ? = nil
4
+ @State private var width : CGFloat = 300
5
+ @State private var selectedView : String ? = nil
6
+ @State private var generation : Int = 0
6
7
7
8
var body : some View {
8
9
VStack {
9
- VStack ( spacing: 50 ) {
10
+ VStack ( spacing: 24 ) {
10
11
HStack ( spacing: 0 ) {
11
12
Rectangle ( ) . fill ( . green)
12
13
. debugLayout ( " green " )
@@ -19,13 +20,19 @@ struct ContentView: View {
19
20
. clearConsole ( )
20
21
. environment ( \. debugLayoutSelection, selectedView)
21
22
. frame ( width: width, height: 80 )
23
+ . id ( generation)
22
24
23
25
LabeledContent {
24
26
Slider ( value: $width, in: 100 ... 500 , step: 1 )
25
27
} label: {
26
28
Text ( " Width: \( width, format: . number. precision ( . fractionLength( 0 ) ) ) " )
27
29
. monospacedDigit ( )
28
30
}
31
+
32
+ Button ( " Reset layout cache " ) {
33
+ generation += 1
34
+ }
35
+ . buttonStyle ( . bordered)
29
36
}
30
37
. padding ( )
31
38
You can’t perform that action at this time.
0 commit comments