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

Transforming a CAShapelayer to a specific size in swift

I'm trying to make a CAShapeLayer with a bezier path in it expand with a view (which is animated, of course). I am aware that I could change the size of the path with CATransform3DMakeScale(, , ) But this won't allow me to make the path an exact…
illuminaté
  • 41
  • 2
  • 3
4
votes
2 answers

Center CAShapeLayer circle in the middle of the screen

I'm drawing a circle via a CAShapeLayer now I want that my circle is centered in the middle of the screen. The circles midpoint must be the middle point of my view. This how I now try to do this: - (void)_initCircle { [_circle…
user1007522
  • 7,858
  • 17
  • 69
  • 113
4
votes
1 answer

UIView with CAShapeLayer does not display CAGradientLayer

I try to apply a radiant to a custom shaped UIView The gradiant category I used if well tested and used in other part of my code. However, I cannot get it to function properly in a custom shaped view created using a CAShapeLayer In my UIView…
Antzi
  • 12,831
  • 7
  • 48
  • 74
4
votes
1 answer

A way to track strokeEnd point of a CAShapeLayer?

My question concerns the possibility of tracking the coordinates of the strokeEnd point of a CAShapeLayer. I have an UISlider, which generates a variable between 0 and 1. I Create an UIBezierPath from a CGMutablePathRef and I assign it as the path…
4
votes
2 answers

How to give zigzag layer separation between two images

I want to merge two images with adding Zigzag border layer between them. Here is example of an image, which i want to integrate in my App. How can i achieve this type of illusion between two images? i've tried Masking image also, but it is not…
Dhruvik
  • 984
  • 4
  • 18
4
votes
1 answer

CAShapeLayer path disappears after animation - need it to stay in the same place

Thanks to some help on StackOverflow, I am currently animating a path in CAShapeLayer to make a triangle that points from a moving sprite to another moving point on the screen. Once the animation completes, the triangle disappears from the screen. I…
KLC
  • 73
  • 1
  • 5
4
votes
1 answer

CAGradientLayer with Angle

I am drawing CGPath which is not rectangle or square,and adding CGPath to CAShapeLayer. This CAShapeLayer's frame getting from CGPath using CGPathGetBoundingBox(path). So it will be rectangle or square. Now i want to set gradient color to layer but…
h999
  • 395
  • 1
  • 5
  • 21
4
votes
0 answers

Get Frame from CGPath

I am working with CGPath and CAShapeLayer. I have drawn non linear path. So how to find frame from CGPath which should be exactly taken space by CGPath? Because I am drawing so many CGPath which are nearer to other CGPath's. Yes I know about…
h999
  • 395
  • 1
  • 5
  • 21
4
votes
1 answer

CAShapeLayer LineCap not proper at end of CABasic Animation

I have implemented a basic line drawing animation for a progress bar.The line has a round cap edge.When I animated the line drawing the beginning of line is having a rounded cap but in the end its a square. below is the code I am using am i missing…
Karthik_S
  • 119
  • 1
  • 8
4
votes
4 answers

CATextLayer gets rasterized too early and it is blurred

I have some troubles with CATextLayer, that could be due to me, but I didn't find any help on this topic. I am on OS X (on iOS it should be the same). I create a CATextLayer layers with scale factor > 1 and what I get is a blurred text. The layer is…
mbt
  • 155
  • 10
4
votes
1 answer

Adding Rounded Corners to UIView without breaking interactions.

This answer works great, Adding Rounded Corners to only top of UITableView? except my UIBarButtonItems are no longer clickable. My guess is that the mask is now sitting on top of the buttons breaking the interaction. Does anyone have any ideas to…
Ryan Romanchuk
  • 10,819
  • 6
  • 37
  • 41
4
votes
1 answer

CAShapeLayer is not drawn in simulator in iPad retina mode

I have a small piece of code, that draws a circle as CAShapeLayer: - (void) viewWillAppear:(BOOL)animated { CGFloat size = MIN(self.view.frame.size.width, self.view.frame.size.height); CAShapeLayer *circleLayer = [CAShapeLayer layer]; …
Zeroid
  • 101
  • 1
  • 6
3
votes
0 answers

How can I draw an NSString (using drawInRect) in front of a layer instead of behind?

In my view's initWithFrame I create a root layer, and then add a sublayer to it. I set the sublayer's path so it will draw a colored box. I want to have text appear on top of the box, so in my view's drawRect, I use NSString's drawInRect method to…
ryleigh
  • 218
  • 2
  • 11
3
votes
2 answers

How to reverse the point order of a CGPath

I want to draw a Circle with Letter punched out of it. to do this, I need to stroke the circle clockwise and the letter counterclockwise. That is all good and well, but when I get the letter path using Core Text I can't figure out how to essentially…
griotspeak
  • 13,022
  • 13
  • 43
  • 54
3
votes
1 answer

Maintaining UIBezierPath above CAShapeLayer

I have a circle added to CAShapeLayer and a line with UIBeizerPath. I want to maintain the position of line to be above circle. Basically in drawRect, position of the items will be maintained one after the other. So, I call drawCircle() first and…
iOS
  • 3,526
  • 3
  • 37
  • 82