swift - 删除列表上的额外间距
问题描述
我不知道如何使 swipeActions 具有黑暗视图的大小,我尝试在下方放置一个垫片或文本,它只会在一些空间中造成更大的混乱。什么是正确的解决方案?
如果不清楚,如果你注意到紫色方块比左边的大,我希望它们的大小相同。
List(someItems, id: \.self) { item in
VStack {
TheView()
}
.swipeActions(allowsFullSwipe: true) { // Adds custom swipe actions
Button {
} label: {
Label("Hide", systemImage: "eye.slash")
}
.tint(.accentColor)
}
.listRowBackground(Color(.red)) // Sets Row color or a custom color: .listRowBackground(Color("DarkBackground"))
.listRowInsets(EdgeInsets()) // Removes extra padding space in rows
.listRowSeparator(.hidden) // Removed lines between items
.cornerRadius(10)
.shadow(radius: 2)
.padding(.bottom)
}
.listStyle(PlainListStyle()) // Removes extra spaces around the whole List
底部的额外空间是因为.padding(.bottom)
,如果我删除它,尺寸是正确的,但是这些项目会全部靠近,我需要一些空间。
编辑:
这是我在上面使用的名为“TheView()”的视图,它并不多,我认为问题不存在。
var body: some View {
VStack {
HStack {
HStack(alignment: .center) {
SomeImage()
}
HStack(alignment: .top) {
VStack {
HStack {
Text("sometext")
.foregroundColor(.primary)
.bold()
Spacer()
}
HStack {
Text(String(xyz!))
.font(.footnote)
.fontWeight(.light)
Spacer()
}
}
HStack {
Text("$515")
.font(.footnote)
.fontWeight(.light)
}
}
}
.padding(5)
.padding(.horizontal, 3)
}
.background(LinearGradient(gradient: Gradient(colors: [Color("SomeColor")]), startPoint: .topLeading, endPoint: .bottomTrailing))
}
解决方案
推荐阅读
- c++ - `=` 分配给新的 std::string 究竟分配了什么?
- php - 如何在当前用户的 eloquent 模型中访问方法
- nelmioapidocbundle - 如何使用 NelmioApiDocBundle(4.x) 为 /api/login_check 和 /api/token/refresh 生成 API 文档
- xamarin.forms - Xamarin Forms:WebView 加载时间非常长
- nestjs - Nestjs 和类验证器 - 至少一个字段不应为空
- blank-line - 如何在每行之间系统地添加新行
- php - php 错误未捕获的错误:调用未定义的函数 mysqli_fetch_all()
- android - 使用 NullPointerException 权限调用 LocationUpdatesService 时应用程序崩溃
- java - 根据 args 具有不同 EditText 的 DetailFragment
- javascript - 当我想返回匿名类型时,函数说返回布尔值