【发布时间】:2019-12-10 12:43:49
【问题描述】:
目前只有红色区域的中间部分是可点击的,我知道下面的区域与navigationBarTitle重叠,但我仍然想知道是否可以让下面的区域也可以点击。
import SwiftUI
struct ContentView: View {
@ObservedObject var taskStore: TaskStore
@State var modalIsPresented = false
var body: some View {
NavigationView {
List {
ForEach(taskStore.tasks) { index in
RowView(task: self.$taskStore.tasks[index])
}
.onMove { sourceIndices, destinationIndex in
self.taskStore.tasks.move(
fromOffsets: sourceIndices,
toOffset: destinationIndex
)
}
.onDelete { indexSet in
self.taskStore.tasks.remove(atOffsets: indexSet)
}
}
.navigationBarTitle("Tasks")
.navigationBarItems(
leading: EditButton(),
trailing:
Button(
action: { self.modalIsPresented = true }
) {
Image(systemName: "plus")
.padding(EdgeInsets(top: 50, leading: 50, bottom: 50, trailing: 10))
.background(Color.red)
}
)
}
.sheet(isPresented: $modalIsPresented) {
NewTaskView(taskStore: self.taskStore)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView( taskStore: TaskStore() )
}
}
【问题讨论】:
标签: ios swift iphone xcode swiftui