uibezierpath

BezierPath and masking

最后都变了- 提交于 2019-12-04 11:00:43
I want to set up UIBezierPath as mask into my view: The goal is something like this: So i draw the View with frame: CGFloat round = 80; UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width/2-105, 0, 210, 60+round)]; myView.backgroundColor = [UIColor redColor]; And then try to add BezierMask: UIBezierPath *aPath = [UIBezierPath bezierPath]; CGSize viewSize = CGSizeMake(myView.frame.size.width, myView.frame.size.height); //(210,80) CGPoint startPoint = CGPointMake(myView.frame.origin.x,myView.frame.origin.y); //(279,0) [aPath moveToPoint:startPoint]; //(279,0) [aPath

Filling a path with a gradient on iOS

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:00:38
问题 On a CAShapeLayer , I've drawn a closed UIBezierPath . I can fill this shape by setting the fillColor , however I want to fill the shape with a gradient. How can I set up the CAGradientLayer so it clips to the shape outlined by the bezier path? 回答1: What you want is a mask. CAGradientlayer has a -setMask method that can clip it to the bounds of your shape like so: [gradientLayer setMask:shapeLayer]; 回答2: A draft example would be the following: ... CGColorSpaceRef colorSpace =

How to rounded the corners when I draw rectangle using UIBezierPath points

懵懂的女人 提交于 2019-12-04 09:44:08
问题 I crated a rectangle using UIBezierPath adding point by point, now I want to rounded the corners of this rectangle but seems there are no way to do it. can anyone help me ? class RectangleLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.5 override init() { super.init() fillColor = Colors.clear.CGColor lineWidth = 5.0 path = rectanglePathStart.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } var rectanglePathStart:

How to draw a gradient color wheel using CAGradientLayer?

柔情痞子 提交于 2019-12-04 08:21:51
问题 I got some reference from these links- What is the Algorithm behind a color wheel? Math behind the Colour Wheel Basic color schemes How to fill a bezier path with gradient color I have gone through the concept of "HSV colour space". But I want to draw a color wheel using RGB with the help of CAGradientLayer . Here is the code snippet of making a color wheel by using simple RGB color array and UIBezierPath - func drawColorWheel() { context?.saveGState() range = CGFloat(100.00 / CGFloat

UIBezierPath stroke 1px line and fill 1px width rectangle - different results.

霸气de小男生 提交于 2019-12-04 07:50:02
问题 Here is a simple drawing - (void)drawRect:(CGRect)rect { //vertical line with 1 px stroking UIBezierPath *vertLine = [[UIBezierPath alloc] init]; [vertLine moveToPoint:CGPointMake(20.0, 10.0)]; [vertLine addLineToPoint:CGPointMake(20.0, 400.0)]; vertLine.lineWidth = 1.0; [[UIColor blackColor] setStroke]; [vertLine stroke]; //vertical rectangle 1px width UIBezierPath *vertRect= [UIBezierPath bezierPathWithRect:CGRectMake(40.0, 10.0, 1.0, 390.0)]; [[UIColor blackColor] setFill]; [vertRect fill]

Unexpected LineJoinStyle behavior when lines in path at 180 degrees

爷,独闯天下 提交于 2019-12-04 07:42:24
I'm getting a clipped LineJoin in a UIBezierPath when one line comes back exactly over the previous line. If I adjust the second line by one pixel, the LineJoin behaves as expected. Here's the code: UIBezierPath *path = [UIBezierPath bezierPath]; [path setLineWidth:10.0f]; [path setLineCapStyle:kCGLineCapRound]; [path setLineJoinStyle:kCGLineJoinRound]; [path moveToPoint:CGPointMake(100, 100)]; [path addLineToPoint:CGPointMake(200, 100)]; [path addLineToPoint:CGPointMake(150, 100)]; [path moveToPoint:CGPointMake(100, 120)]; [path addLineToPoint:CGPointMake(200, 120)]; [path addLineToPoint

How to animate a human written stroke using Swift/iOS?

强颜欢笑 提交于 2019-12-04 07:33:25
问题 Objective I am attempting to create an animated approximation of human writing, using a UIBezierPath generated from a glyph. I understand and I have read the many UIBezierPath questions which sound similar to mine (but are not the same). My goal is to create an animation that approximates the look of a human performing the writing of characters and letters. Background I've created a playground that I am using to better understand paths for use in animating glyphs as if they were drawn by hand

Masking an image using bezierpath with image's full resolution

。_饼干妹妹 提交于 2019-12-04 05:10:49
问题 Hi, I have a path (shape) and a high-resolution image. I make the high res image to be AspectFit inside the view on which I draw the path and I want to mask the image with the path but at the full resolution of the image, not at the resolution in which we see the path. The problem, It works perfectly when I don't upscale them up for high-resolution masking but when I do, everything is messed up. The mask gets stretched and the origins don't make sense. All I want is to be able to upscale the

Apply rounded corners to arc created with UIBezierPath

孤街醉人 提交于 2019-12-04 04:09:17
I am working on a circular progress bar that i've created using UIBezierPath. The progress bar looks like the following picture: My question is: how to make the edge of the arc rounded and not rectangular? The code i used to draw the arc looks like is: // Draw the arc with bezier path int radius = 100; arc = [CAShapeLayer layer]; arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:M_PI endAngle:M_PI/150 clockwise:YES].CGPath; arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius, CGRectGetMidY(self.view.frame)-radius); arc.fillColor =

clip-masking uiview with CAShapeLayer and UIBezierPath

偶尔善良 提交于 2019-12-04 03:43:44
I have a problem clipping a view using CAShapeLayer-UIBezierPath , I want to clip the content but I end up getting a stroke (frame) with that UIBezierPath , This is my code UIBezierPath *path2Path = [UIBezierPath bezierPath]; [path2Path moveToPoint:CGPointMake(206.745, 0)]; [path2Path addLineToPoint:CGPointMake(206.745, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 0)]; [path2Path addLineToPoint:CGPointMake(87.28, 0)]; [path2Path addCurveToPoint:CGPointMake(103.808, 12.118) controlPoint1:CGPointMake(87.28, 0) controlPoint2:CGPointMake(86