Skip to content

Commit 7710a19

Browse files
committed
add examples
1 parent e638af2 commit 7710a19

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Guide.docc/Articles/ProvideModifierWithParameter.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ SwiftUIでは、条件に応じてViewの見た目や振る舞いを変更する
1313
引数のないmodifierを条件分岐によって切り替えるには、`if`文を使用する必要があります:
1414

1515
```swift
16-
1716
struct ContentView: View {
1817
@State var condition = false
1918

2019
var body: some View {
21-
xxx
20+
if condition {
21+
Text("nice")
22+
.nicelyStyled()
23+
} else {
24+
Text("nice")
25+
}
2226
}
2327
}
2428
```
@@ -30,5 +34,12 @@ struct ContentView: View {
3034
引数を持つmodifierを提供すると、条件分岐を引数に移動することで同一のView identityで表現できます:
3135

3236
```swift
33-
xxx
37+
struct ContentView: View {
38+
@State var condition = false
39+
40+
var body: some View {
41+
Text("nice")
42+
.textStyle(condition ? .nicely : .primary)
43+
}
44+
}
3445
```

0 commit comments

Comments
 (0)