How to draw a circle path with color gradient stroke
问题 I want to draw a circle with color gradient stroke like the following picture, on both iOS and macOS: Is it possible to implement with CAShapeLayer or NSBezierPath / CGPath ? Or any other ways? 回答1: In macOS 10.14 and later (as well as in iOS 12 and later), you can create a CAGradientLayer with a type of .conic , and then mask it with a circular arc. For example, for macOS: class GradientArcView: NSView { var startColor: NSColor = .white { didSet { setNeedsDisplay(bounds) } } var endColor: