[英]SwiftUI .shadow blocks List scroll gesture for all but first List {}. Why?
if I place 2 or more Lists with items in VStack or HStack and give the Vstack.shadow attribute, only the first List is scrollable and receives "gesture" events.如果我在 VStack 或 HStack 中放置 2 个或更多带有项目的列表并提供 Vstack.shadow 属性,则只有第一个列表是可滚动的并接收“手势”事件。 Anybody has an idea why and is this intended behaviour?
任何人都知道为什么,这是预期的行为吗? Seems like a bug to me.
对我来说似乎是一个错误。 Tried on Xcode and device with iOS 14 and 14.+
在 Xcode 和带有 iOS 14 和 14 的设备上进行了尝试。+
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
ListView1()
ListView2()
}
.shadow(radius: 5)
}
}
struct ListView1:View {
var values=["1","2","3"]
var body: some View {
List {
ForEach(values, id: \.self) { (value) in
Text("Value \(value)")
}
}
}
}
struct ListView2:View {
var values=["5","6","7"]
var body: some View {
List {
ForEach(values, id: \.self) { (value) in
Text("Value \(value)")
}
}
}
}
Use compositingGroup() for solving issue!使用compositingGroup()解决问题!
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
ListView1()
ListView2()
}
.compositingGroup() // <<: Here!
.shadow(radius: 5)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.