【发布时间】:2020-08-14 16:09:15
【问题描述】:
我想制作一个 ScrollView,让我可以从底部滚动到顶部。 基本上我有一个渐变背景(底部 - 黑色,顶部 - 白色)。当我设置 ScrollView 时,我可以从白色向下滚动到黑色。我希望应用程序从 ScrollView 的底部开始,让我可以向上滚动。 (从黑到白)
谢谢!
当前代码:
struct ContentView: View {
var body: some View {
ScrollView(.vertical/*, showsIndicators: false*/){
VStack(spacing: 0) {
ForEach ((0..<4).reversed(), id: \.self) {
Image("background\($0)").resizable()
.aspectRatio(contentMode: .fill)
.frame(width: UIScreen.main.bounds.width ,height:1000)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.red)
}
.edgesIgnoringSafeArea(.all)
}
}
【问题讨论】:
-
谢谢!它解决了:)
标签: xcode uiscrollview swiftui scrollview xcode11