質問編集履歴
1
質問内容の編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,12 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
おそらくMainViewが原因なのではないかなと思ってます。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
▼ContentView
|
18
|
+
|
13
19
|
```Swift
|
14
20
|
|
15
21
|
import SwiftUI
|
@@ -118,6 +124,150 @@
|
|
118
124
|
|
119
125
|
|
120
126
|
|
127
|
+
▼MainView
|
128
|
+
|
129
|
+
```swift
|
130
|
+
|
131
|
+
import SwiftUI
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
struct MainView: View {
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
@State private var navBarTitle: String = "TOP"
|
140
|
+
|
141
|
+
@State private var isNewViewShown: Bool = false
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
var body: some View {
|
146
|
+
|
147
|
+
NavigationView(){
|
148
|
+
|
149
|
+
TabView(selection: $navBarTitle){
|
150
|
+
|
151
|
+
AView().tabItem{
|
152
|
+
|
153
|
+
Label("aaa", systemImage: "house")
|
154
|
+
|
155
|
+
}.tag("aaa")
|
156
|
+
|
157
|
+
BView().tabItem{
|
158
|
+
|
159
|
+
Label("bbb", systemImage: "antenna.radiowaves.left.and.right")
|
160
|
+
|
161
|
+
}.tag("bbbb")
|
162
|
+
|
163
|
+
CView().tabItem{
|
164
|
+
|
165
|
+
Label("ccc", systemImage: "checkmark.square")
|
166
|
+
|
167
|
+
}.tag("ccc")
|
168
|
+
|
169
|
+
DView().tabItem{
|
170
|
+
|
171
|
+
Label("ddd", systemImage: "text.bubble")
|
172
|
+
|
173
|
+
}.tag("ddd")
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
.navigationBarTitle(Text(self.navBarTitle), displayMode: .inline)
|
178
|
+
|
179
|
+
.navigationBarItems(
|
180
|
+
|
181
|
+
leading:
|
182
|
+
|
183
|
+
Button(action: {
|
184
|
+
|
185
|
+
print("通知ボタンが押されました。")
|
186
|
+
|
187
|
+
}, label: {
|
188
|
+
|
189
|
+
Image(systemName: "bell")
|
190
|
+
|
191
|
+
.renderingMode(.template)
|
192
|
+
|
193
|
+
.foregroundColor(.white)
|
194
|
+
|
195
|
+
}),
|
196
|
+
|
197
|
+
trailing:
|
198
|
+
|
199
|
+
Button(action: {
|
200
|
+
|
201
|
+
print("検索ボタンが押されました。")
|
202
|
+
|
203
|
+
}, label: {
|
204
|
+
|
205
|
+
Image(systemName: "magnifyingglass")
|
206
|
+
|
207
|
+
.renderingMode(.template)
|
208
|
+
|
209
|
+
.foregroundColor(.white)
|
210
|
+
|
211
|
+
})
|
212
|
+
|
213
|
+
)
|
214
|
+
|
215
|
+
.overlay(
|
216
|
+
|
217
|
+
Button(action: {
|
218
|
+
|
219
|
+
print("新規投稿ボタンが押されました。")
|
220
|
+
|
221
|
+
self.isNewPostViewShown = true
|
222
|
+
|
223
|
+
}, label: {
|
224
|
+
|
225
|
+
Image(systemName: "plus.circle")
|
226
|
+
|
227
|
+
.resizable()
|
228
|
+
|
229
|
+
.frame(width: 40.0, height: 40.0, alignment: .leading)
|
230
|
+
|
231
|
+
.background(Color.white)
|
232
|
+
|
233
|
+
.foregroundColor(.gray)
|
234
|
+
|
235
|
+
.clipShape(Circle())
|
236
|
+
|
237
|
+
})
|
238
|
+
|
239
|
+
.offset(x: 0, y: -30), alignment: .bottom
|
240
|
+
|
241
|
+
)
|
242
|
+
|
243
|
+
.sheet(isPresented: self.$isNewViewShown){
|
244
|
+
|
245
|
+
NewView()
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
struct MainView_Previews: PreviewProvider {
|
258
|
+
|
259
|
+
static var previews: some View {
|
260
|
+
|
261
|
+
MainView()
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
```
|
270
|
+
|
121
271
|
▼参考サイト
|
122
272
|
|
123
273
|
https://d1v1b.com/swiftui/twitter_home_menu
|