Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created August 7, 2025 21:19
Show Gist options
  • Save amosgyamfi/b9fb404fcc1fc14b735f84095b8f7552 to your computer and use it in GitHub Desktop.
Save amosgyamfi/b9fb404fcc1fc14b735f84095b8f7552 to your computer and use it in GitHub Desktop.
//
// ImageGeneratingView.swift
// SwiftUIiOS26
//
// Created by Amos Gyamfi on 29.7.2025.
//
import SwiftUI
struct ImageGeneratingView: View {
@State private var isDrawing: Bool = false
var body: some View {
PhaseAnimator([false, true]) { generating in
ZStack {
Circle()
.stroke(style: StrokeStyle(lineWidth: 4))
.frame(width: 128, height: 128)
.opacity(0.25)
Circle()
.trim(from: 0.0, to: generating ? 1.0 : 0.0)
.stroke(style: StrokeStyle(lineWidth: 4, lineCap: .round, lineJoin: .round))
.frame(width: 128, height: 128)
.rotationEffect(Angle(degrees: -90))
.animation(.easeOut.speed(0.01).repeatForever(autoreverses: false), value: isDrawing)
.onAppear {
isDrawing.toggle()
}
HStack(alignment: .bottom, spacing: -120) {
VStack {
Image(.circ)
.scaleEffect(generating ? 0.5 : 1)
.offset(x: generating ? 0 : 120)
.animation(.easeInOut.speed(0.5).repeatForever(autoreverses: true), value: generating)
Image(.smallTriangle)
.scaleEffect(y: generating ? 1 : 0.5, anchor: .bottom)
.animation(.easeOut.speed(0.5).repeatForever(autoreverses: true), value: generating)
}
Image(.largeTriangle)
.scaleEffect(y: generating ? 1 : 0.5, anchor: .bottom)
.animation(.easeInOut.speed(0.5).repeatForever(autoreverses: true), value: generating)
}
.scaleEffect(0.2)
}
}
}
}
#Preview {
ImageGeneratingView()
.preferredColorScheme(.dark)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment