I'm using SwiftUI 3.0 ScrollView
, when I tap the status bar to scroll to top, the scroll animation suffers from stuttering/ flickering... this is a recording of a slowdown animation, showing the problem.
Problem Demonstrationn
This is the fruit details View:
import SwiftUI
struct FruitDetailsView: View {
var fruit: Fruit
var body: some View {
NavigationView {
ScrollView(.vertical, showsIndicators: true) {
VStack(alignment: .center, spacing: 20) {
VStack(alignment: .leading, spacing: 20) {
FruitsHeaderView(fruit: fruit)
.aspectRatio(1, contentMode: .fit)
.cornerRadius(16)
Text(fruit.title)
.font(.largeTitle)
.fontWeight(.heavy)
.foregroundColor(fruit.gradientColors[1])
Text(fruit.headline)
.font(.headline)
.multilineTextAlignment(.leading)
Text("Learn more about \(fruit.title)".uppercased())
.fontWeight(.bold)
.foregroundColor(fruit.gradientColors[1])
Text(fruit.description)
.multilineTextAlignment(.leading)
}
.padding(.horizontal, 20)
.frame(maxWidth: 640, alignment: .center)
}
}
.padding(.top, -1.0)
}
.navigationBarTitle(fruit.title, displayMode: .automatic)
}
}
struct FruitDetailsView_Previews: PreviewProvider {
static var previews: some View {
FruitDetailsView(fruit: fruitsData[0])
}
}
this is the FruitsHeaderView...
import SwiftUI
struct FruitsHeaderView: View {
var fruit: Fruit
@State private var isAnimating: Bool = false
var body: some View {
ZStack {
LinearGradient(gradient: Gradient(colors: fruit.gradientColors), startPoint: .topLeading, endPoint: .bottomTrailing)
Image(fruit.image)
.resizable()
.scaledToFit()
.shadow(color: .black.opacity(0.15), radius: 8, x: 6, y: 8)
.padding(.vertical, 20)
}
.frame(minHeight: 200)
.aspectRatio(1.0, contentMode: .fill)
}
}
struct FruitsHeaderView_Previews: PreviewProvider {
static var previews: some View {
FruitsHeaderView(fruit: fruitsData[0])
.previewLayout(.fixed(width: 375, height: 440))
}
}