首页 > 解决方案 > SwiftUI Horizo​​ntal ScrollView 项目在 iOS 14.3 中滚动时变得不可见,但在 iOS 13 中工作正常

问题描述

在此处输入图像描述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)

                }
            }}

标签: swiftuiios14swiftui-scrollview

解决方案


罪魁祸首是 .cornerRadius(20, corners: [.topLeft, .topRight]) 将其更改为 .cornerRadius(20) 并且工作正常


推荐阅读