Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// CircularProgress.swift
// Time!
//
// Created by Eric Lewis on 6/9/19.
// Copyright © 2019 Eric Lewis, Inc. All rights reserved.
//
import SwiftUI
struct CakeView: View {
@Binding var percent: TimeInterval;
init(_ percent: Binding<TimeInterval>) {
$percent = percent
}
var body: some View {
ZStack {
Circle().stroke(Color.blue, lineWidth: 2)
GeometryReader { geometry in
Path { path in
let width: CGFloat = min(geometry.size.width, geometry.size.height)
let height = width
let middle = width / 2.0
path.move(
to: CGPoint(
x: middle,
y: height * 0.5
)
)
let middlePoint = CGPoint(
x: middle,
y: height * 0.5
)
path.addArc(center: middlePoint, radius: width * 0.45, startAngle: .degrees(-90), endAngle: .degrees(-90 + (3.6 * self.percent)), clockwise: false)
path.addLine(to: middlePoint)
path.closeSubpath()
}
.fill(Color.blue)
.aspectRatio(1, contentMode: .fit)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.