【问题标题】:How to change the background of item in foreach embedded in list while using onMove()?使用onMove()时如何更改嵌入列表中的foreach项目的背景?
【发布时间】:2022-11-08 04:33:43
【问题描述】:

这是我的代码 `

List {
    ForEach(timerListVM.editTimerList.timerList, id: \.self) { timer in
        AddTimerRowView(timer: timer)
            .listRowSeparator(.hidden)
            .listRowInsets(.init(top: 4, leading: 0, bottom: 8, trailing: 0))
    }
    .onMove { indexSet, index in
        timerListVM.editTimerList.timerList.move(fromOffsets: indexSet, toOffset: index)
    }
}
.listStyle(.plain)
.frame(maxWidth: .infinity)

` 我使用 listRowInsets() 在项目之间放置一些空间,但是当我按下一个项目时,它会得到白色背景和阴影。

如何隐藏背景并让项目被阴影包裹?

【问题讨论】:

    标签: swiftui swiftui-list


    【解决方案1】:

    您可以使用.padding(.all).padding()

    【讨论】:

    • 不是 .padding(.all) 只有 .padding()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多