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
1
vote
2 answers

Get Touch point in CAShapelayer

i am drawing line by this code: - (void) drawLine:(float)x :(float)y:(float)toX:(float)toY { CAShapeLayer *lineShape = nil; CGMutablePathRef linePath = nil; linePath = CGPathCreateMutable(); lineShape = [CAShapeLayer layer]; lineShape.lineWidth =…
PJR
  • 13,052
  • 13
  • 64
  • 104
1
vote
1 answer

How to custom CALayer using subclassing

On UIView there are number of CALayers. Each CALayer consists of CAShapeLayers. CAShapeLayers' path property consists of UIBezierPath. My objective is when i tap on CALayer i want to get points which i used in the drawing of UIBezierPath. For that i…
Harsh
  • 666
  • 1
  • 10
  • 21
1
vote
1 answer

How to change polygon shape in CAShapeLayer by tapping its corners?

I am drawing a CAShapeLayer with a polygon with 8 corners. I want to change the shape of the polygon by dragging one or multiple corners at a time. How can i achieve this? CHeers AF
Abolfoooud
  • 2,663
  • 2
  • 27
  • 27
1
vote
1 answer

Swift iOS: Determine if bezier path intersects with UIView frame?

I’ve created a custom UIView that draws a UIBezierPath, assigns it to a CAShapeLayer, and then masks it to the UIView’s root layer. Now what I’m trying to do is determine if a different UIView is intersecting (or overlapping) any part of the bezier…
user4496950
  • 93
  • 1
  • 1
  • 11
1
vote
1 answer

How to create ripples effect continuously and repeat the process after some delay in Swift

I am working on an iOS app where I need to create ripple effect on a UIView. I am able to create the ripple effect but I am not able to customise it. This is what I want to achive: This is my current output What I want to achieve is create 4-5…
George
  • 3,600
  • 2
  • 26
  • 36
1
vote
1 answer

CAShapeLayer path color changes

So, I know the title of my question may not be the most descriptive so I'll run through it here: Basically what I have is view with an image (using a layer's contents property) and under that layer I have a Drawing layer which is a CAShapeLayer. In…
johnnyd
  • 101
  • 1
  • 3
1
vote
1 answer

How can i draw lines from touches in single CAShapeLayer to be able to select and move UIBezierPaths?

I'm trying to draw lines with touches and then be able to move it. i didn't use UIContext method with draw(_ rect: CGRect) for drawing because i wasn't able to get size of stroke and some of it's properties, so i used CAShapeLayer for drawing with…
1
vote
2 answers

How to remove only one line from LineView?

by my code I can draw multiple straight lines one by one on a view. now what I want is, to remove only one line when click Undo button. I have write single line to remove last draw line in undoButtonAction, but it removes whole view. i have search a…
Hiren
  • 11
  • 3
1
vote
1 answer

The effect displayed by SKShapeNode is different from that of CAShapelayer

I am going to use SKShapeNode to display a Bezier curve graph, but the displayed effect is very strange, and it is not the same as the one displayed by CAShapeLayer. I don't know what is wrong. Does anyone know the problem? Here is a screenshot of…
iCode
  • 13
  • 4
1
vote
2 answers

CAShapeLayer Image Not Appearing

I have an image.cgImage that I set as the contents to a CAShapeLayer() but it's not appearing. I force unwrap the image so I know that it definitely exists. The round shape appears but the image inside of it doesn't. let shapeLayer =…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
1
vote
1 answer

Mask a gradient layer with the intersection of two shape layers in Swift

I have two shapes of type CAShapeLayer (e.g. one box and a circle) and a gradient layer of type CAGradientLayer. How can I mask the gradient layer with the intersection of the two shapes like this picture in Swift?
Asteroid
  • 1,049
  • 2
  • 8
  • 16
1
vote
1 answer

Giving a CAShapeLayer a 3d effect

I am playing around with countdown timer in swift. What I want to give the countdown circle a 3D shadow of effect. the code below will operate the countdown time perfectly but i guess its more of the visuals i am trying to edit with it. is there…
kitchen800
  • 197
  • 1
  • 12
  • 36
1
vote
2 answers

How to use lineJoin and lineJoinStyle with a UIBezierPath?

I have a mask applied to a view using CAShapeLayer and UIBezierPath. I'd like to add a rounding effect to the line joins but it's not working. How do I round the corners of this shape? You can plug the following into an Xcode playground. import…
lurning too koad
  • 2,698
  • 1
  • 17
  • 47
1
vote
1 answer

changing size of CALayer also changes size of previously added layer's size

i'm trying to draw over UIImageView with this custome class and i would like to be able to change the size and color of lines being drawn by user. But every time i change the size or color of CALayer Previously added layer's color and size also…
Ramesh Sanghar
  • 174
  • 1
  • 1
  • 19
1
vote
0 answers

UIBezierPath combine shapes

This is not asking the same question as How can I combine UIBezierPath drawings? even though the name is similar I have a shape that needs to be able to scale vertically and on one side of it are rounded corners and the other side is some other…
ashipma
  • 423
  • 5
  • 15