Created
April 25, 2021 04:38
-
-
Save ilamanov/8f63a6501f0735f6567df7052b93225d to your computer and use it in GitHub Desktop.
Creating SwiftPieChart: PieSliceView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PieSliceView: View { | |
var pieSliceData: PieSliceData | |
var body: some View { | |
GeometryReader { geometry in | |
Path { path in | |
let width: CGFloat = min(geometry.size.width, geometry.size.height) | |
let height = width | |
let center = CGPoint(x: width * 0.5, y: height * 0.5) | |
path.move(to: center) | |
path.addArc( | |
center: center, | |
radius: width * 0.5, | |
startAngle: Angle(degrees: -90.0) + pieSliceData.startAngle, | |
endAngle: Angle(degrees: -90.0) + pieSliceData.endAngle, | |
clockwise: false) | |
} | |
.fill(pieSliceData.color) | |
} | |
.aspectRatio(1, contentMode: .fit) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment