質問編集履歴
1
質問内容の編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
ただ、下側から上にスワイプすると期待通りに左部からメニューが表示されます。
|
5
5
|
なぜ、左からのスワイプではなく下からのスワイプ判定になっているのでしょうか。
|
6
6
|
|
7
|
+
おそらくMainViewが原因なのではないかなと思ってます。
|
8
|
+
|
9
|
+
▼ContentView
|
7
10
|
```Swift
|
8
11
|
import SwiftUI
|
9
12
|
|
@@ -58,5 +61,77 @@
|
|
58
61
|
|
59
62
|
```
|
60
63
|
|
64
|
+
▼MainView
|
65
|
+
```swift
|
66
|
+
import SwiftUI
|
67
|
+
|
68
|
+
struct MainView: View {
|
69
|
+
|
70
|
+
@State private var navBarTitle: String = "TOP"
|
71
|
+
@State private var isNewViewShown: Bool = false
|
72
|
+
|
73
|
+
var body: some View {
|
74
|
+
NavigationView(){
|
75
|
+
TabView(selection: $navBarTitle){
|
76
|
+
AView().tabItem{
|
77
|
+
Label("aaa", systemImage: "house")
|
78
|
+
}.tag("aaa")
|
79
|
+
BView().tabItem{
|
80
|
+
Label("bbb", systemImage: "antenna.radiowaves.left.and.right")
|
81
|
+
}.tag("bbbb")
|
82
|
+
CView().tabItem{
|
83
|
+
Label("ccc", systemImage: "checkmark.square")
|
84
|
+
}.tag("ccc")
|
85
|
+
DView().tabItem{
|
86
|
+
Label("ddd", systemImage: "text.bubble")
|
87
|
+
}.tag("ddd")
|
88
|
+
}
|
89
|
+
.navigationBarTitle(Text(self.navBarTitle), displayMode: .inline)
|
90
|
+
.navigationBarItems(
|
91
|
+
leading:
|
92
|
+
Button(action: {
|
93
|
+
print("通知ボタンが押されました。")
|
94
|
+
}, label: {
|
95
|
+
Image(systemName: "bell")
|
96
|
+
.renderingMode(.template)
|
97
|
+
.foregroundColor(.white)
|
98
|
+
}),
|
99
|
+
trailing:
|
100
|
+
Button(action: {
|
101
|
+
print("検索ボタンが押されました。")
|
102
|
+
}, label: {
|
103
|
+
Image(systemName: "magnifyingglass")
|
104
|
+
.renderingMode(.template)
|
105
|
+
.foregroundColor(.white)
|
106
|
+
})
|
107
|
+
)
|
108
|
+
.overlay(
|
109
|
+
Button(action: {
|
110
|
+
print("新規投稿ボタンが押されました。")
|
111
|
+
self.isNewPostViewShown = true
|
112
|
+
}, label: {
|
113
|
+
Image(systemName: "plus.circle")
|
114
|
+
.resizable()
|
115
|
+
.frame(width: 40.0, height: 40.0, alignment: .leading)
|
116
|
+
.background(Color.white)
|
117
|
+
.foregroundColor(.gray)
|
118
|
+
.clipShape(Circle())
|
119
|
+
})
|
120
|
+
.offset(x: 0, y: -30), alignment: .bottom
|
121
|
+
)
|
122
|
+
.sheet(isPresented: self.$isNewViewShown){
|
123
|
+
NewView()
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
struct MainView_Previews: PreviewProvider {
|
130
|
+
static var previews: some View {
|
131
|
+
MainView()
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
```
|
61
136
|
▼参考サイト
|
62
137
|
https://d1v1b.com/swiftui/twitter_home_menu
|