Questions tagged [cashapelayer]

CAShapeLayer is a special purpose CALayer subclass for drawing animatable shapes using cubic Bezier splines. It's a part of the QuartzCore framework and is available for both iOS (since iOS 3.0) and OS X (since OS X v10.6 "Snow Leopard").

CAShapeLayer is a special purpose CALayer subclass for drawing animatable shapes using cubic Bezier splines. It's a part of the framework and is available for both (since iOS 3.0) and (since OS X v10.6 "Snow Leopard").

The shapes is defined using the path property and can be both filled and stroked using the fillColor and strokeColor properties. Note that the backgroundColor property inherited from CALayer does not fill the shape. The path of the shape is animatable (but doesn't support implicit animations) but the appearance of the animation is undefined if the two paths have a different number of control points or segments.

There are several properties (animatable) to configure how the shape is stroked and filled. Using these properties the stroke can for example get a moving dashed patten (commonly called "marching ants").

The strokeStart and strokeEnd properties can also be used to only stroke part of the shape or to animate the shape being stroked. Both values go from 0.0 (beginning of path) to 1.0 (end of path) and values in between are interpolated along the path.


The page about Paths in the Quartz 2D Programming Guide is a great resource for learning more about creating paths, stroking, rounding and joining paths, filling paths and creating dash patterns.

951 questions
2
votes
1 answer

CAShapeLayer strokeColor get mix with fillColor

I have made a hexagonal View with border. The problem I am facing now is I am not able to set the desired color for border which I have made using strokeWidth (not borderWidth) and now my layer's strokeColor get mix with fill color of the…
SandeepAggarwal
  • 1,273
  • 3
  • 14
  • 38
2
votes
1 answer

How to prevent CAShapeLayer from drawing before CABasicAnimation starts

I written "space" separated progress circle in which I animate the progress sequentialy. Method is being called 3 times with diffrent progress and arc number. The problem is - the BezierPaths draws theirselfs before animation starts and they…
yershuachu
  • 778
  • 8
  • 19
2
votes
0 answers

How to render image of UIView containing UIBezierPath subviews

I have a UIView that contains some subviews - drawn using UIBezierPath. Every subview contains a scrollview having image as mask. When I try to render image of whole view (overall), instead of making image from path, it draws image of individual…
NightFury
  • 13,436
  • 6
  • 71
  • 120
2
votes
1 answer

CAShapeLayer - Performance with an explicit path

The CGPath property of CAShapeLayer has the following sentence in it's documentation: Specifying an explicit path usually improves rendering performance. What is an "explicit" path? And how does setting an explicit path improve the render…
Max
  • 2,699
  • 2
  • 27
  • 50
2
votes
1 answer

Clipping a UIImage to a custom UIBezierPath while preserving the image quality

I'm having a problem when it comes to clipping a photo to a custom UIBezierPath. Instead of displaying the area within the path, as it should, it displays another part of the photo instead (of different size and position than where it should be, but…
thebradbain
  • 3,139
  • 4
  • 16
  • 17
2
votes
2 answers

CAShapeLayer mask view

I have one problem. I look for the answers on the net and I don't understand why is not working. I must do some stupid mistake which I can't figure it out. if I make : - (void)viewDidLoad { [super viewDidLoad]; UIView * view = [[UIView…
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
2
votes
1 answer

Detecting touch point in a line

I am not able to find the touch point in the line drawn using UIBezierpath. CGPathContainPoint is not working for line. Please help me out
Shruthi
  • 45
  • 3
2
votes
3 answers

iOS: CAShape Layer Path Transformation

I have used CAShape Layer before doing basic transformation on paths - from a smaller circle into a larger circle. Good enough, but then I tried to transform a triangle into a circle; it worked, but the transformation is weird. Other words, from one…
Unheilig
  • 16,196
  • 193
  • 68
  • 98
2
votes
1 answer

Detecting Touches on Rotated CAShapeLayer

I'm trying to implement a UI element using a custom CALayer inside of a custom UIView. Basically, the user moves a slider with his/her finger around a circle, so I have a layer for interaction, and then a sublayer of that that is of type…
Rick S.
  • 55
  • 3
2
votes
1 answer

Geographical maps with SVGKIT

I am trying to find my way using SVGKit (https://github.com/SVGKit/SVGKit) for an iOS project dealing with geographical maps. At this point, I can access a particular area on a map using a CALayer object. That lets me access the rectangle…
Michel
  • 10,303
  • 17
  • 82
  • 179
2
votes
1 answer

How can set a CAShapeLayer transparent in Objective-C?

I'm trying to setup a inset shadow on a UIButton, Thanks to other SO posts, I've managed to do this : UIBezierPath *buttonPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius]; …
Olivier
  • 3,431
  • 5
  • 39
  • 56
2
votes
1 answer

How to plot a graph with CAShapeLayer?

Is it possible to draw just a curve with a given line width using CAShapeLayer? It seems it can only draw filled shapes. I want to draw an animated plot graph. Just a line, not a shape.
Proud Member
  • 40,078
  • 47
  • 146
  • 231
2
votes
1 answer

How to change color of intersected parts of CAShapeLayer in Objective-C?

I am trying to draw CGPaths using CAShapeLayer. I want to change the color of the parts where lines are intersected. Following screenshots explain the goal…
Can Leloğlu
  • 271
  • 1
  • 4
  • 11
2
votes
1 answer

Resizing CAShapeLayer

I have a simple test app on which my rootViewController's UIView contains a bunch of UIView subviews. Each one of those UIView subview is backed by a CAShapeLayer. I want the composition created by those subviews ( the four shapes that are within…
alphabox
  • 21
  • 4
1
vote
1 answer

Draw two parallel line using CAShape Layer

I am drawing single line by CAShapeLayer *lineShape = nil; CGMutablePathRef linePath = nil; linePath = CGPathCreateMutable(); lineShape = [CAShapeLayer layer]; lineShape.lineWidth = 1.0f; lineShape.lineCap = kCALineJoinMiter; lineShape.strokeColor…
PJR
  • 13,052
  • 13
  • 64
  • 104