![](/img/trans.png)
[英]Adding `.onTapGesture` modifier to part of the row view in List makes "Drag to reorder" not working in some area of the row view
[英]Why does adding ".shadow" modifier to a List makes ".onMove" modifier not working anymore?
運行在macOS(11.7.2)上,代碼如下:
struct ContentView: View {
@State private var users = ["Paul", "Taylor", "Adele"]
var body: some View {
List {
ForEach(users, id: \.self) { user in
Text(user)
}
.onMove { a, b in
print(a,b)
}
}
.frame(width: 200,height: 200)
.background(Color.white)
.cornerRadius(10)
.position(x: 500, y:300)
//.shadow(color: Color.black.opacity(0.2), radius: 10)
}
}
如果我注釋掉.shadow
修飾符, .onMove
的閉包就會被執行,否則不會。
為什么會這樣? 我怎樣才能解決這個問題? .shadow
是如何影響.onMove
? 這是我最好奇的部分,有什么建議嗎?
如果您在背景之前設置陰影,它會起作用。 像這樣:
List {
ForEach(users, id: \.self) { user in
Text(user)
.foregroundColor(.red)
}.onMove { a, b in
print(a,b)
}
}
.frame(width: 200,height: 200)
.shadow(color: Color.black.opacity(0.2), radius: 10)
.background(Color.white)
.cornerRadius(10)
.position(x: 500, y:300)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.