简体   繁体   English

SwiftUI.shadow 阻止除第一个列表 {} 之外的所有列表滚动手势。 为什么?

[英]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.

相关问题 SwiftUI 点击手势阻止列表中的项目删除操作 - SwiftUI tap gesture blocks item deleting action in List SwiftUI 使用 ontap 手势从列表中选择一个值 - SwiftUI pick a value from a list with ontap gesture 为什么我的 SwiftUI 列表没有填充我的所有数据? - Why is my SwiftUI List not being populating with all my data? SwiftUI 列表重置滚动任何视图更改 - SwiftUI List reset scroll on any view change 为什么此视图仅获取第一个值,而不是所有列表值? - Why does this view only grab the first value, not all the list values? SwiftUI:NavigationView 中列表的导航标题卡在原位(滚动动画损坏) - SwiftUI: Navigation Title Stuck in Place (Scroll Animation Broken) for List in NavigationView 删除列表中除第一项以外的所有项目 - Remove all but the first item in a list 使用python比较两个列表。 为什么Python将第一个列表的第一个数字与第二个列表的所有数字进行比较? - Using python to compare two lists. Why Python compares the first number of the first list with all the numbers of the second list? 在列表中标识TRUE块 - Identifying blocks of TRUEs in list 为什么我的 SwiftUI 列表选择在选择时没有突出显示? - Why is my SwiftUI List selection not highlighting when selected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM