Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Last active November 14, 2022 11:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/e0d6493bc9bb5a608f2d68773e517ea0 to your computer and use it in GitHub Desktop.
Save amosgyamfi/e0d6493bc9bb5a608f2d68773e517ea0 to your computer and use it in GitHub Desktop.
Looping SwiftUI Animation
//
// StreamLogoLaunch.swift
// StreamiOSChatSDKPrototyping
//
// Created by amos.gyamfi on 14.10.2021.
//
import SwiftUI
struct StreamLogoLaunch: View {
@State private var move = false
let StreamBlue = Color(#colorLiteral(red: 0, green: 0.368627451, blue: 1, alpha: 1))
@State private var swinging = false
var body: some View {
if #available(iOS 15.0, *) {
ZStack {
StreamBlue
.opacity(0.25)
.ignoresSafeArea()
ZStack {
Image("STREAMMARK")
.scaleEffect(0.6)
.rotationEffect(.degrees(swinging ? -10 : 10), anchor: swinging ? .bottomLeading : .bottomTrailing)
.offset(y: -15)
.animation(.easeInOut(duration: 1).repeatCount(14, autoreverses: true), value: swinging)
VStack(spacing: -46) {
Image("stream_wave")
.offset(y: 20)
.offset(x: move ? -160 : 160)
.animation(.linear(duration: 14), value: move)
Image("stream_wave")
.offset(y: 10)
.offset(x: move ? -150 : 150)
.animation(.linear(duration: 14), value: move)
.task {
move.toggle()
swinging.toggle()
}
}
.mask(Image("wave_top"))
}
// Change size here
.scaleEffect(2)
}
//.clipShape(Circle()
//.trim(from: 1/2, to: 1)
//)// All Views
} else {
// Fallback on earlier versions
}
}
}
struct StreamLogoLaunch_Previews: PreviewProvider {
static var previews: some View {
StreamLogoLaunch()
//.preferredColorScheme(.dark)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment