cashapelayer

CAShapeLayer strokeStart and strokeEnd positions

三世轮回 提交于 2019-12-04 07:43:56
I have this piece of code: let arcPath = UIBezierPath(ovalInRect: CGRectMake(0, 0, frame.width, frame.height)) circleLayer = CAShapeLayer() circleLayer.path = arcPath.CGPath circleLayer.fillColor = UIColor.clearColor().CGColor circleLayer.strokeColor = UIColor.blueColor().CGColor circleLayer.lineWidth = 5.0; circleLayer.strokeStart = 0 circleLayer.strokeEnd = 0.7 which results like this: As you can see, the arc starts on the right side of the circle. I would like to draw the arc starting from the top. How would I do that? Do I have to rotate the whole thing by -90 degrees to accomplish what I

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

start and end angle of UIBezierPath?

ⅰ亾dé卋堺 提交于 2019-12-04 01:33:28
I have coded as below for half circle in iOS using UIBezierPath and CAShapeLayer . clockWiseLayer = [[CAShapeLayer alloc] init]; CGFloat startAngle = -M_PI_2; CGFloat endAngle = M_PI + M_PI_2; CGFloat width = CGRectGetWidth(imageView.frame)/2.0f + 30; CGFloat height = CGRectGetHeight(imageView.frame)/2.0f +50; CGPoint centerPoint = CGPointMake(width, height); float radius = CGRectGetWidth(imageView.frame)/2+10; clockWiseLayer.path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES].CGPath; clockWiseLayer.fillColor = [UIColor

CAShapeLayer filling with another CAShapeLayer as a mask

女生的网名这么多〃 提交于 2019-12-03 22:28:50
My question is about filling animation one CAShapeLayer with another CAShapeLayer . So, I wrote some code that almost achieves my goal. I created a based layer and fill it with another. Code below: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _shapeLayer = [CAShapeLayer layer]; [self drawBackgroundLayer]; } // my main/backgound layer - (void)drawBackgroundLayer { _shapeLayer.frame = CGRectMake(0, 0, 250, 250); _shapeLayer.lineWidth = 3; _shapeLayer.strokeColor = [UIColor blackColor].CGColor; _shapeLayer.fillColor = UIColor

CAShapeLayer shadow

≯℡__Kan透↙ 提交于 2019-12-03 21:36:05
Given the following CAShapeLayer is it possible to add a drop shadow like the following image at the tip? I'm using a UIBezierPath to draw the bars. - (CAShapeLayer *)gaugeCircleLayer { if (_gaugeCircleLayer == nil) { _gaugeCircleLayer = [CAShapeLayer layer]; _gaugeCircleLayer.lineWidth = self.gaugeWidth; _gaugeCircleLayer.fillColor = [UIColor clearColor].CGColor; _gaugeCircleLayer.strokeColor = self.gaugeTintColor.CGColor; _gaugeCircleLayer.strokeStart = 0.0f; _gaugeCircleLayer.strokeEnd = self.value; _gaugeCircleLayer.lineCap = kCALineCapRound; _gaugeCircleLayer.masksToBounds = NO;

iOS核心动画笔记6-专用图层

有些话、适合烂在心里 提交于 2019-12-03 16:40:28
专用图层 1. CAShapeLayer CAShapeLayer 是一个通过矢量图形而不是bitmap来绘制的图层子类. 可以指定绘制颜色, 线宽等属性, 用CGPath来定义想要绘制的图形, 最后CAShapeLayer就会自动渲染出来了. 相比使用 CoreAnimation直接在layer上绘制图形, CAShapeLayer有以下优势: 渲染快速. CAShapeLayer使用硬件加速, 绘制同一图形会比用CoreGraphics快很多. 高效使用内存. 一个CAShapeLayer不需要像普通CALayer一样创建一个寄宿图形, 所以无论有多大, 都不会占用太多的内存. 不会被图形边缘剪切掉. CAShapeLayer可以在边界之外绘制, 图层路径不会像使用CoreGraphics的普通CALayer一样被剪裁掉. 不会出现像素化. 当给CAShapeLayer做3D变换时候, 它不会像一个有寄宿图的普通图层一样变得像素画. 1.1 创建一个CGPath CAShapeLayer上绘制的形状可以通过CGPath来表示, CGPath对象可以直接创建, 更好的是通过UIBezierPath创建CGPath(这种方法不需要手动释放内存, 方便管理). 图层路径不一定是闭合的. 也可以是开放的. 1.2 创建圆角 前面提到创建圆角视图的方法,

How to give cornerRadius for UIBezierPath

我的梦境 提交于 2019-12-03 13:18:04
I created a rectangle using following code and now I need to rounded the corners of this rectangle. but I can't find a property called layer.cornerRadius, can anyone help me ? class OvalLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.3 override init() { super.init() fillColor = Colors.green.CGColor path = ovalPathSmall.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } var ovalPathStart: UIBezierPath { let path = UIBezierPath(ovalInRect: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)) return path } } You can use below

Swift draw shadow to a uibezier path

廉价感情. 提交于 2019-12-03 09:42:34
I have a strange question. Even though I did read a lot of tutorials on how to do this, the final result only shows the bezier line, not any shadow whatsoever. My code is pretty simple : let borderLine = UIBezierPath() borderLine.moveToPoint(CGPoint(x:0, y: y! - 1)) borderLine.addLineToPoint(CGPoint(x: x!, y: y! - 1)) borderLine.lineWidth = 2 UIColor.blackColor().setStroke() borderLine.stroke() let shadowLayer = CAShapeLayer() shadowLayer.shadowOpacity = 1 shadowLayer.shadowOffset = CGSize(width: 0,height: 1) shadowLayer.shadowColor = UIColor.redColor().CGColor shadowLayer.shadowRadius = 1

CAShapeLayer Shadow with UIBezierPath

£可爱£侵袭症+ 提交于 2019-12-03 08:53:37
This question continues from a previous answer . I have the following CAShapeLayer : - (CAShapeLayer *)gaugeCircleLayer { if (_gaugeCircleLayer == nil) { _gaugeCircleLayer = [CAShapeLayer layer]; _gaugeCircleLayer.lineWidth = self.gaugeWidth; _gaugeCircleLayer.fillColor = [UIColor clearColor].CGColor; _gaugeCircleLayer.strokeColor = self.gaugeTintColor.CGColor; _gaugeCircleLayer.strokeStart = 0.0f; _gaugeCircleLayer.strokeEnd = self.value; _gaugeCircleLayer.lineCap = kCALineCapRound; _gaugeCircleLayer.path = [self insideCirclePath].CGPath; CAShapeLayer *cap = [CAShapeLayer layer]; cap

Need a tip with UIBezierPath. Triangle Shape like Instagram Sign Up View

南笙酒味 提交于 2019-12-03 08:36:11
I'm trying to create a bezier path like the instagram triangle in the picture below, however I must be doing something wrong. The Bezier path does not show! - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; [self drawTriangle]; } - (IBAction)closeButton:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)drawTriangle{ UIBezierPath* trianglePath = [UIBezierPath bezierPath]; [trianglePath moveToPoint:CGPointMake(self.signUpButton.center.x, self