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
3
votes
1 answer

How to draw Arc with curved edge in iOS?

In one of my application, I am trying to draw a gradient arc with rounded edges. Like the following image. This is what I have done so far using the following code. -(void)startArc { UIBezierPath *roundedArc = [self…
Bharath
  • 3,001
  • 6
  • 32
  • 65
3
votes
1 answer

Why CALayer and CAShapeLayer behaving differently

First I created the CAShapeLayer for masking the UIView at the bottom with height of 10px like this: CAShapeLayer *mask = [[CAShapeLayer alloc]init]; CGRect maskRect = CGRectMake(0, self.view.frame.size.height-10, self.view.frame.size.width,…
S.J
  • 3,063
  • 3
  • 33
  • 66
3
votes
1 answer

CAShapeLayer with UIRectCornerBottomLeft/Right makes my view disappear

OK. I have done the Google search, the Stack search, the Wenderlich search (is that a meme yet?). I have tried every thing here on overflow and nothing is working. I need a CALayer expert. I have a tableView that I'm showing as a dropdown from…
addzo
  • 845
  • 3
  • 13
  • 37
3
votes
2 answers

iOS: CAShapeLayer, Change color of outer layer

I am currently using CAShapeLayer for one of my requirement. I was successful in implementing the fillcolor, strokecolor, etc... but I wanted to change the color of outer part of that CAShapeLayer. I tried doing it with backgroundcolor, & followed…
iYoung
  • 3,596
  • 3
  • 32
  • 59
3
votes
0 answers

Masking CAGradientLayer to CAShape layer

Help needed: I've got a problem with creating a shape that is filled with a gradient. To create the shape, I am using a CAShape layer and masking it with a CGPath showing an arrow. This does work. However, I can only mask the CAGradient layer if I…
user1612877
  • 391
  • 1
  • 5
  • 19
3
votes
0 answers

Disable backing store on CAShapeLayer or subclass CALayer to prevent "bogus layer size" warning

I want to overlay a large CATiledLayer with some vector drawing. To get started I'd like to use CAShapeLayer, which is to be replaced by some custom CALayer subclass or delegate. The good part is that it works. However, I get this warning on every…
mvds
  • 45,755
  • 8
  • 102
  • 111
3
votes
4 answers

CAShapeLayer animation doesn't stay on screen but disappears

I'm trying to draw a animated circle but every segment needs to have another color. Now everything works except that my piece that is just drawed before I call the method again disappears so only the last part stays. I don't want that, I want that…
user1007522
  • 7,858
  • 17
  • 69
  • 113
3
votes
1 answer

How to get CAShapeLayer() circle to resize based on the size class

I'm trying to create a circle using CGPoint and CGFloat. But I want the circle to be different in siz based on which device is used. I changed all my Size classes to reflect the sizes I want and I was hoping, it would recognise that but it doesn't.…
Ace Green
  • 381
  • 5
  • 29
3
votes
1 answer

Union or logical or on two CGPaths (or CAShapeLayers) to create one

I'm trying to do a Union of multiple CGPaths in iOS. How can I do this? I've tried adding combining paths using "path.AddPath()" but I get this weird artifacting as if it's doing a Join instead of a Union. I've also tried using…
LampShade
  • 2,675
  • 5
  • 30
  • 60
3
votes
1 answer

CAShapeLayer shadow

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) { …
gotnull
  • 26,454
  • 22
  • 137
  • 203
3
votes
1 answer

How can I resize and translate a CAShapeLayer?

I have a CAShapeLayer drawn from a UIBezierPath but for some reason the translation and scale applied on the bezier did not carry over to the CAShapeLayer when it was drawn. Is there any way of applying the same transformations to it? Here is the…
Infineon Labs
  • 91
  • 1
  • 11
3
votes
1 answer

iOS "erase" drawing with CAShapeLayer animated

I'm trying to implement a circular indicator that draws itself with animation as values change. I use CAShapeLayer to draw with animation. So far I got it to draw itself from the beginning each time, it works as intended. Now I want to make it more…
NKorotkov
  • 3,591
  • 1
  • 24
  • 38
3
votes
2 answers

Setting CALayer maskToBounds causing layer to disappear

I am trying to create a circle which is filled depending upon a certain percentage. Here is pic of the effect I am going for: I have a UIView and to this I add a CAShapeLayer which draws the circle. I am then creating another UIShapeLayer as a…
pls
  • 1,522
  • 2
  • 21
  • 41
3
votes
1 answer

how to draw CALayer with line path like simulate eraser effect?

I want to simulate eraser effect with touch event to show a image that behind something block on top, eg, gray color; Something like that: I have find for a long time for the solution but I can't do it well. following is my custom view…
Steve Lai
  • 633
  • 1
  • 7
  • 18
3
votes
1 answer

Reverse UIBezierPath for single sided corners

I want to create a mask path whose final output will be a corner with a concave face. I have created a UIBezierPath using the -bezierPathWithRoundedRect:byRoundingCorners:cornerRadii: method and specified that only one corner need to be rounded (in…
staticVoidMan
  • 19,275
  • 6
  • 69
  • 98