-4

An example of how I would want the moveUp animation to work is similar to how Apple's stock app looks on first run, as seen below:

enter image description here

You can use my code available on this link: SwiftUI - in sheet have a fixed continue button that is not scrollable

Then I want to chain this with another animation that repeats forever but, this move up animation must only happen once

ItsZiaW
  • 180
  • 2
  • 14

1 Answers1

0

Try this -

import SwiftUI

struct ContentView: View {
    @State private var offsetY: CGFloat = 150
    @State private var opacityAmount: Double = 0
    @State private var animationAmount: CGFloat = 1
    var body: some View {
        VStack {
            HStack {
                Image(systemName: "sparkle").foregroundColor(.yellow)
                    .offset(y: offsetY)
                    .opacity(opacityAmount)
                    .animation(
                        Animation.easeOut(duration: 0.5).delay(0.1)
                    )
                    .scaleEffect(animationAmount)
                    .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true))
                Text("All new design").font(.largeTitle)
                    .offset(y: offsetY)
                    .opacity(opacityAmount)
                    .animation(
                        Animation.easeOut(duration: 0.5).delay(0.1)
                    )
            }
                
            Text("Flexible").font(.largeTitle)
                .offset(y: offsetY)
                .opacity(opacityAmount)
                .animation(
                    Animation.easeOut(duration: 0.5).delay(0.2)
                )
                .onAppear {
                    offsetY = 0
                    opacityAmount = 0.8
                    animationAmount = 1.5
                }
            Spacer()
        }
    }
}