【发布时间】:2020-10-28 12:29:15
【问题描述】:
我有一个包含以下项目的列表:
List {
ForEach(filteredItems, id: \.self) { item in
Text(item.termLowerCase)
.font(fontItems)
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.contentShape(Rectangle())
.onTapGesture {
// doSomething()
}
.onDelete { offsets in
print("deleting"
}
.listRowBackground(
Group {
if item == selectedItem {
Color("selectedColor").mask(RoundedRectangle(cornerRadius: 20))
} else {
Color.clear
}
}
.padding(EdgeInsets(top: 0, leading: 5, bottom: 0, trailing: 5))
)
此代码生成如下元素,包括所选元素的圆角。
我的问题是这种单元格装饰会阻止滑动单元格向左删除以工作
我该如何解决?
- 我想要整个单元格,从左到右,可点击,而不仅仅是单词。
- 我想向左滑动。
【问题讨论】:
-
我无法重现该问题,但我必须对其进行修改才能编译。代码格式不好,缺少括号,并且您没有在视图顶部显示变量是如何声明的。
标签: swift swiftui swiftui-list