回答編集履歴

1

全体のコードを追記しました。

2022/11/06 08:57

投稿

退会済みユーザー
test CHANGED
@@ -15,3 +15,54 @@
15
15
  navigationBarItemsはDeprecatedになっているみたいですので、注意して使った方が良いみたいですね。
16
16
  [navigationBarItems(leading:) | Apple Developer Documentation](https://developer.apple.com/documentation/swiftui/view/navigationbaritems(leading:))
17
17
 
18
+ ### 追記です。
19
+
20
+ コメントありがとうございます。
21
+
22
+ ContentView全体のコードを記載します。
23
+ *手元の環境ではこれでエラーはなくなりました
24
+
25
+ ```swift
26
+ struct ContentView: View {
27
+ var body: some View {
28
+ NavigationView {
29
+ ZStack {
30
+ Image("backgroundTimer")
31
+ .resizable()
32
+ .edgesIgnoringSafeArea(.all)
33
+ .aspectRatio(contentMode: .fill)
34
+ VStack(spacing: 30.0) {
35
+ Text("残り10秒")
36
+ .font(.largeTitle)
37
+ HStack {
38
+ Button(action: {
39
+ }) {
40
+ Text("スタート")
41
+ .font(.title)
42
+ .foregroundColor(Color.white)
43
+ .frame(width: 140, height: 140)
44
+ .background(Color("startColor"))
45
+ .clipShape(Circle())
46
+ }
47
+ Button(action: {
48
+ }) {
49
+ Text("ストップ")
50
+ .font(.title)
51
+ .foregroundColor(Color.white)
52
+ .frame(width: 140, height: 140)
53
+ .background(Color("stopColor"))
54
+ .clipShape(Circle())
55
+ }
56
+ }
57
+ }
58
+ }
59
+ .navigationBarItems(trailing:
60
+ NavigationLink(destination: SettingView()) {
61
+ Text("秒数設定")
62
+ }
63
+ )
64
+ }
65
+ }
66
+ }
67
+ ```
68
+