nsbezierpath

IOS : Animate transformation from a line to a bezier curve

假装没事ソ 提交于 2019-11-27 09:47:56
问题 I would like to animate a straight line curving into a bezier curve (from "_" to "n"), is there a library somewhere that can help me to do it ? I know how to draw a Bezier curve with UIBezierPath, I could redraw rapidly and progressively do the transformation, but if something already does that it would be cool :-) 回答1: I might do something with a CADisplayLink . For example, you could do this in your view controller using a CAShapeLayer , e.g.: #import "ViewController.h" #import <QuartzCore

How to draw a circle path with color gradient stroke

家住魔仙堡 提交于 2019-11-27 09:08:12
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? 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: NSColor = .blue { didSet { setNeedsDisplay(bounds) } } var lineWidth: CGFloat = 3 { didSet { setNeedsDisplay

NSBezierPath drawing

早过忘川 提交于 2019-11-27 00:32:02
问题 I want to do a rounded rectangle outline on an NSImage and I figured that using NSBezierPath would be the best way. However, I ran into a problem: instead of drawing a nice curve, I get this: For reasons I can't understand, NSBezierPath is drawing the rounded part with a darker color than the rest. Here's the code I'm using (inside a drawRect: call on a custom view): NSBezierPath* bp = [NSBezierPath bezierPathWithRoundedRect: self.bounds xRadius: 5 yRadius: 5]; [[[NSColor blackColor]

How to draw a circle path with color gradient stroke

大憨熊 提交于 2019-11-26 14:32:23
问题 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: