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

CAShapeLayer with CAShapeLayer sublayer slow

I have a UIScrollView with CAShapeLayer sub layer that renders a simple line. The CAShapeLayer sublayer has its own sub CAShapeLayer. This causes scrolling and zooming to be slow. The hierarchy is like this: -UIScrollViewLayer -CAShapeLayer …
Imran
  • 1,488
  • 1
  • 15
  • 36
0
votes
1 answer

'Cut' a shape out of UIView or AVCaptureVideoPreviewLayer iPhone

I have a AVCaptureVideoPreviewLayer that needs to be cut so that it sits nicely onto my image that has parts that are transparent that need to be seen. What is the best / efficient way to cut a shape out of the AVCaptureVideoPreviewLayer? I have…
Dan
  • 1,447
  • 2
  • 14
  • 30
-1
votes
1 answer

My CAShapeLayer is not well centered in my View

I wan't to draw a circle in the grey View but it is not perfectly centered and I can't understand why. I get the center of my view (circleView) and put it in the circle's center then i had CAShapeLayers to the superview let shapeLayer =…
-1
votes
1 answer

How to edit and update number on same player?

my app part is based on canvas. #What I want to do? I need dictionary to track and save particular player's key and value.because, I want to store player1 on key "1" and player2 on key "2", suppose user change player 2's number, then player 2's…
Hiren
  • 11
  • 3
-1
votes
1 answer

How to make circular loading animation color go from red to green as it loads

I have implemented a circular loading animation exactly as in this video: https://www.youtube.com/watch?v=O3ltwjDJaMk Here is my code: class ViewController: UIViewController { let shapeLayer = CAShapeLayer() override func viewDidLoad() { …
Pontus
  • 44
  • 13
-1
votes
1 answer

CAShapeLayer not going away

I have a class that adds a progress view to a given UIView. I use this in a collection view in its cells. It looks good on the first couple of cells, but after swiping a few times you can see faint marks that should be there. I will attach…
Noah Iarrobino
  • 1,435
  • 1
  • 10
  • 31
-1
votes
1 answer

How to draw same bezier path multiple times after finished the previous one?

I am using bezier path, shape layer and CABasicAnimation to draw view animately. But it draw view only single time. How to draw same bezier path multiple times after finished the previous one ? This is the attached code for creating this type of…
Rahul Chopra
  • 187
  • 1
  • 13
-1
votes
2 answers

Swift: Why CAShapeLayer's Stroke and LineWidth drawn from Center

I am trying for PieChart which having dynamic datas. On clicking each Pie, it has to highlight and rest are in normal state. Dynamically changing lineWidth of CAShapeLayer, but lineWidth increasing from middle path. It has to increase from bottom to…
McDonal_11
  • 3,935
  • 6
  • 24
  • 55
-1
votes
1 answer

CAGradientLayer not fit perfectly on UITableViewCell bounds

i am developing simple UITableView with custom UITableViewCell with Xib file i have added MainView and pin it to ContentView in order to add all my views inside MainView as shown below UITableViewCell layout when i try to add CAGradientLayer to…
Mamad
  • 71
  • 7
-1
votes
2 answers

Swift - How to draw 3 diamond like baseball field with CAShapeLayer?

I have a view controller. Inside, i have a view (A) and in this view (A) I want to draw 3 diamond like a baseball field with CAShapeLayer. You can see an example what i want to draw, below. But I don't know how to do it ? Can you please help me…
kirusamma
  • 119
  • 11
-1
votes
1 answer

Why is the CAShapeLayer I create in draw not successfully animating?

There are several S.O. questions out there about CA Shape Layers not successfully animating, and I've looked through them but I can't figure out what my error is (although I think it's a basic misunderstanding of how to use CA Layers. I'm trying to…
-1
votes
2 answers

Semi circle between 2 CGPoints

I want to draw a semi circle between 2 points on a circle. The main represents a clock and i want to draw another line to represent a progress from one hour to another so the points position may vary. First of all i know the X and Y of the 2 points…
Vlad.D
  • 127
  • 9
-1
votes
2 answers

How to use UIBezierPath() on CAShapeLayer() multiple times for same view swift 5

I want to cut off the upper and lower portion of a container view in my table view cell using UIBezierPath() & CAShapeLayer(). The code is as follows: func cutView() { let containerViewHeight: CGFloat = containerView.frame.height let…
Tulon
  • 4,011
  • 6
  • 36
  • 56
-1
votes
1 answer

CATransaction Animation Issue

I have a CAShapeLayer and trying to animate few properties. I did use CABasicAnimation in the beginning, but since this loops over and over, I need the most officient way to do it. Folowing code animates properly: private func…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
-1
votes
1 answer

i am developing an image edittor app for IOS.How can i add an eraser option?

Currently i am adding the changes as subview to the original image. I want to add an eraser tool so that when the user draws on the screen, the subviews will be cleared and the underlined image will be seen . Same as an eraser tool in "Paint".Below…
Faheem Rahman
  • 343
  • 2
  • 10