Skip to content

Instantly share code, notes, and snippets.

@AndresR173
Created November 21, 2019 14:00
Show Gist options
  • Save AndresR173/0cf9816cb8b9ed8e92616374faf40507 to your computer and use it in GitHub Desktop.
Save AndresR173/0cf9816cb8b9ed8e92616374faf40507 to your computer and use it in GitHub Desktop.
Apple Watch ring animation based on DesignCode tutorials
//
// AnimatedRing.swift
// AnimatedRing
//
// Created by Andres Rojas on 21/11/19.
// Copyright © 2019 Andres Rojas. All rights reserved.
//
import SwiftUI
struct RingAnimation: View {
@State var show = false
var body: some View {
Circle()
.trim(from: show ? 0.1 : 0.99, to: 1)
.stroke(Color.blue, style: StrokeStyle(lineWidth: 10, lineCap: .round, lineJoin: .round))
.rotationEffect(.degrees(90))
.rotation3DEffect(Angle(degrees: 180), axis: (x: 1, y: 0, z: 0))
.frame(width: 100, height: 100)
.animation(.easeOut)
.onTapGesture {
self.show.toggle()
}
}
}
struct AnimatedRing_Previews: PreviewProvider {
static var previews: some View {
RingAnimation()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment