Skip to content

Instantly share code, notes, and snippets.

@Inncoder
Created October 2, 2020 10:59
Show Gist options
  • Select an option

  • Save Inncoder/64af60ed702e3f75aba4ecf3bf4b0911 to your computer and use it in GitHub Desktop.

Select an option

Save Inncoder/64af60ed702e3f75aba4ecf3bf4b0911 to your computer and use it in GitHub Desktop.
Loaing screen?
//
// Created by Inncoder on 01/10/2020.
// Copyright © 2020 Inncoder AS. All rights reserved.
//
import SwiftUI
struct CircleLoading: View {
@State private var rotation: Double = 0
var body: some View {
ZStack {
Circle()
.fill(color)
.frame(width: circleSize, height: circleSize)
ForEach(0..<count) { i in
Circle()
.trim(from: 0.0, to: 0.1 + CGFloat(i / 6))
.stroke(color, style: StrokeStyle(lineWidth: 10, lineCap: .round))
.frame(width: circleSize + 20 + CGFloat(i * 30), height: circleSize + 20 + CGFloat(i * 30))
.rotationEffect(.degrees(rotation))
.animation(Animation.linear(duration: 3.0 / Double(count - i)).repeatForever(autoreverses: false))
}
}
.onAppear() {
rotation = -360
}
}
// MARK: - Drawing constants
let circleSize: CGFloat = 30
let count: Int = 6
let color = RadialGradient(gradient: Gradient(colors: [.blue, .green]), center: .center, startRadius: 0, endRadius: 115)
}
struct CircleLoading_Previews: PreviewProvider {
static var previews: some View {
CircleLoading()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment