Reputation: 3257
In a SwiftUI List
that is in Edit
mode, each row has a handle at its trailing edge so that the row can be moved up or down in the sequence of rows. In UIKit there is an instance method tableView(_:canMoveRowAt:)
which specifies which rows contains those handles and which do not.
I'm seeking the equivalent in SwiftUI. Any ideas?
Upvotes: 3
Views: 1602
Reputation: 257503
You need to use .moveDisabled(condition)
modifier, like in below example
ForEach(items, id: \.self) { item in
Text(item)
.moveDisabled(item == "nonmovable item") // << conditional !!
}
Upvotes: 10