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

Circle animation iOS UIKit behaviour with tail not completing fully

So I'm trying to learn how to draw circles in UIKit and I've got them pretty much figured it out but I'm just trying to implement one more thing. In the video below when the tail of the circle reaches the end I would like for the tail to not reach…
Simon McNeil
  • 293
  • 1
  • 13
1
vote
0 answers

How to achieve this animation with multiple CAShapeLayer

I'm having a lot of trouble exporting a video with animated layers. The final goal is to export to a video (that's why I need this done with CALayers) a moving CAShapeLayer around the screen and a line following its trace. First of all, I have an…
1
vote
1 answer

Swift How to mask UIView content

I should mask this rounded UIImageView: to get this kind of result: Is it possible obtain it using some core's utility? (maybe using something like UIBezierPath or CAShapeLayer). I really don't know where to start.
Leonardo
  • 218
  • 4
  • 17
1
vote
1 answer

Shape in ios swift

how to draw the curve with blur background? here I have attached my code but am not getting the exact output @IBDesignable class CurvedHeaderView: UIView { @IBInspectable var curveHeight:CGFloat = 50.0 var curvedLayer = CAShapeLayer() override func…
Manikandan S
  • 115
  • 3
  • 18
1
vote
0 answers

Swift - Make CAShapeLayer glow effect

I have made a circle progress view that looks like this: This is the current code for the CAShapeLayer: import UIKit class CircularProgressView: UIView { fileprivate var progressLayer = CAShapeLayer() fileprivate var trackLayer =…
Erik Auranaune
  • 1,384
  • 1
  • 12
  • 27
1
vote
1 answer

Group Animation in ios

I'm making a custom loader which has circular shaped layer inside and It will animate in two way. First shape will animate pulsing like scaling it's radius increase and decrease with infinite time and in same time it will rotate inside the view with…
1
vote
1 answer

Pulsing Animation on layer

I'm making some custom type of loader for an app where I just simply make 4 circular layers inside my view and it all set and display fine. but when I apply pulsing animation scaling of all layers they disturb all my design and layer scaling fine…
1
vote
1 answer

make CAShapeLayer and CGPath conform to Codable or to NSCoding

I'm trying to save and get info about CAShapeLayers at .json files, using Codable protocol, but have an error: public class Node: Codable { public var name: String = "" public var path: CGPath? public var baseLayer: CAShapeLayer? public…
nastassia
  • 807
  • 1
  • 12
  • 31
1
vote
1 answer

Why does CAShapeLayer exist?

I'm trying to understand CAShapeLayer and where it shines. It seems like the main advantage is the shape style properties that you can conveniently access: let shapeLayer = CAShapeLayer() shapeLayer.frame = CGRect(origin: CGPoint(x: 100, y: 100),…
Kevvv
  • 3,655
  • 10
  • 44
  • 90
1
vote
1 answer

Problem with scaling animation of CAShapeLayer

I created simple path for tooltip of a slider. I wanted it to animate as it appears so a user would know that he can drag it. But it does not animate: let upperToolTipPath: CAShapeLayer = CAShapeLayer() var path =…
1
vote
1 answer

draw line using uibezierPath in a vertical way

My swift code below draws a horiziontal way the horizontal line is at a angle that does not change. Think like a x axis. I want to draw a line in the exact opposite way. Think of the y axis. The line is drawn at bezier.addLine(to: CGPoint(x:…
joe buck
  • 31
  • 1
  • 7
1
vote
1 answer

How to do this shape with UIBezierPath

I'm trying to convert my UIView to this shape with UIBezierPath, currently I'm only able to do the left bottom corner, seeking for help for adding other corners. Code for left bottom only. let mask = CAShapeLayer() mask.frame =…
Emre Akcan
  • 982
  • 10
  • 27
1
vote
1 answer

Border only in corners with UIBezierPath() wrong space in lineDashPattern

Im trying to create a view with border only in corners (qrCode style) using lineDashPattern, but the space between the lines doesn't seem to match with the Pattern defined by me. This is my playground: override func loadView() { let view =…
ios_dev
  • 359
  • 2
  • 13
1
vote
1 answer

iOS - How to set a CATextLayer inside a CAShapeLayer which is drawn with a custom UIBezierPath?

I want to program a custom pie menu. In the code below you see how I create a pie menu with two items. My structure is the following: I'm using a rectengular UIBezierPath with a CAShapeLayer as the context as my circular background. Inside my…
M. Schwarze
  • 59
  • 1
  • 5
1
vote
1 answer

How to draw parallelogram like figure in iOS?

I should achieve following result: As you see, it contains list of parallelograms(not rectangular) with label inside of it. Also, it can be dynamic, which means I can use stackview. First of all, let's draw our parallelogram like view: class…
neo
  • 1,314
  • 2
  • 14
  • 34