【问题标题】:SwiftUI Horizontal ScrollView item becomes invisible when scroll in iOS 14.3 but works fine in iOS 13SwiftUI Horizo​​ntal ScrollView 项目在 iOS 14.3 中滚动时变得不可见,但在 iOS 13 中工作正常
【发布时间】:2021-01-28 06:36:15
【问题描述】:

SwiftUI Horizo​​ntal ScrollView 项目在 iOS 14.3 中滚动时变得不可见,但在 iOS 13 中可以正常工作

    GeometryReader { geometry in
            ZStack (alignment: .center) {
                       Color(UIColor(hexString: "#F2F2F7"))
                       .edgesIgnoringSafeArea(.all)
                VStack(alignment: .center){


                  ScrollView (.horizontal, showsIndicators: false) {
                 LazyHStack {
                     //contents
                       ForEach(0..<200)
                          { index in
                         Text(String(index))
                    }
                 }}
                .frame(maxWidth: .infinity)      // << here !!
                .frame(height: 100)

                }
            }}

【问题讨论】:

  • 提供的代码在 Xcode 12.3 iOS 14.3 上运行良好。此外,LazyHStack 不适用于 iOS 13。因此请提供完整的复制代码。
  • 对我也很有效,但需要使用:Text(String(index)) 或 Text("(index)")
  • @Raja 是的,LazyHStack 在 iOS 13 中不可用,但对于 iOS 13,我只使用了 HStack
  • @workingdog 完成了同样的问题
  • @AdeyemiSeun 请添加完整结构

标签: swiftui ios14 swiftui-scrollview


【解决方案1】:

罪魁祸首是 .cornerRadius(20, corners: [.topLeft, .topRight]) 将其更改为 .cornerRadius(20) 并且效果很好

猜你喜欢
  • 2021-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 2016-12-01
  • 1970-01-01
  • 2018-08-08
  • 1970-01-01
相关资源
最近更新 更多