Create a circle with multi coloured segments in Core Graphics
问题 I am trying to draw a pie chart which will be made up of equal sized segments, each with a different colour. I am basing my code off this SO: Draw a circular segment progress in SWIFT let circlePath = UIBezierPath(ovalInRect: CGRect(x: 200, y: 200, width: 150, height: 150)) var segments: [CAShapeLayer] = [] let segmentAngle: CGFloat = 1.0 / CGFloat(totalSegments) for var i = 0; i < totalSegments; i++ { let circleLayer = CAShapeLayer() circleLayer.path = circlePath.CGPath // start angle is