David Weiss is in search of a canonical reply:
I am in search of a SwiftUI native means to do that frequent re-order activity with customized UI.
Once I try to maneuver these rows I get a white background round every of my customized rows:
And once I try to tug to reorder the row within the Record disappears:
Here is the code I am utilizing:
import SwiftUI
import SwiftData
struct PrioritizeAreas: View {
@State non-public var classes: [CategoryItem] = [CategoryItem(category: “A”, sortOrder: 0),
CategoryItem(category: “B”, sortOrder: 1),
CategoryItem(category: “C”, sortOrder: 2)]
var physique: some View {
ZStack {
LinearGradient(colours: [.green, .indigo], startPoint: .prime, endPoint: .backside).ignoresSafeArea()
Record {
ForEach(classes) { merchandise in
Textual content(merchandise.class)
.font(.system(measurement: 14, weight: .semibold, design: .rounded))
.foregroundStyle(Shade.white)
.body(top: 42)
.padding(.horizontal)
.body(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 22)
.foregroundStyle(.orange.blendMode(.regular).opacity(1))
}
}
.onMove { indices, newOffset in
classes.transfer(fromOffsets: indices, toOffset: newOffset)
}
.listRowSeparator(.hidden)
.listRowInsets(EdgeInsets(prime: 4, main: 0, backside: 4, trailing: 0))
.listRowBackground(Shade.clear)
}
.listStyle(.insetGrouped)
.scrollContentBackground(.hidden)
}
}
non-public struct CategoryItem: Identifiable {
var id = UUID()
let class: String
let sortOrder: Int
}
}
#Preview {
NavigationStack {
PrioritizeAreas()
}
}
How do you take away these visible artifacts when reordering a SwiftUI record?
Word: The background is a linear gradient that I wish to protect.
That is on iOS 17.4 utilizing Xcode Model 15.4 (15F31d)