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

How to place SKSpriteNode in front of CAShapeLayer?

I want to display a SKSpriteNode in front of a CAShapeLayer and this is the code that I am using : import SpriteKit import GameplayKit import UIKit class GameScene: SKScene { let progressLayer = CAShapeLayer() override func didMove(to…
Oliver Redeyoff
  • 177
  • 2
  • 14
3
votes
2 answers

Drawing a path in Photoshop/Illustrator, using it in iOS

I am looking for a more convenient way of drawing a path than by drawing it programmatically. Is there any way of drawing a path in Photoshop (or Illustrator) and getting that path to the iPhone to use in a CAKeyframeAnimation? e.g. by exporting the…
Joseph Tura
  • 6,290
  • 8
  • 47
  • 73
3
votes
1 answer

Draw a line with CAShapeLayer

I want to show a line like this: Here is my code: import UIKit @IBDesignable class ProgressView: UIView { let π = CGFloat(M_PI) var levelProgress: CGFloat = 0.0 { didSet { self.fgLayer.strokeEnd = levelProgress …
Twitter khuong291
  • 11,328
  • 15
  • 80
  • 116
3
votes
0 answers

How to change the frame of striped progress bar in iOS?

i want to obtain the progress bar like in the image below: Striped loading progress bar with triangle at the end Here is what i've done so far, with the help of the project from github https://github.com/iluuu1994/ITProgressBar-iOS, so here is what…
Andrew M.
  • 31
  • 3
3
votes
0 answers

Rotating Around Certain CGPoint

How to rotate around a certain CGPoint from the Given UIView. The following images defines a CAShapeLayer around which there were four UIView's as top, left, bottom and right: I have added UIRotationGesture to self.view through which I am rotating…
3
votes
1 answer

Draw only corners to ImageVIew frame

I am trying to draw only corners to ImageView frame. For this I used CAShapeLayer and Bezier path and working fine with dotted lines around the UIImageView frame. But requirement is something more like, have to show only corners. Things which I…
Saheb Singh
  • 555
  • 4
  • 18
3
votes
0 answers

How to restrict multiple arc layer moment in iOS/Swift?

I have requirement to develop below UI screen ios using Swift. Requirement Screen In above two circles each segment movement is allowed either to push or pull to other circle. I have written below code to achieve it import UIKit class…
3
votes
1 answer

How to draw detected rectangle path on live camera feed using CAShapeLayer and UIBezeirPath

I am developing an application to detect rectangles in a live camera feed and highlight the detected rectangle. I did camera thing using AVFoundation and used below methods in order to do detect and highlight the detected rectangle. var detector:…
Hanushka Suren
  • 723
  • 3
  • 10
  • 32
3
votes
1 answer

Algorithm to determine closed contour in iOS

How to determine a shape created using CAShapeLayer by applying UIBezierPath is closed contour or not? Which algorithm used to determine the same. As following 2 images: one representing that it has closed contour and other has not. Image with…
Bhargav Soni
  • 1,067
  • 1
  • 9
  • 22
3
votes
2 answers

Check UIBezierPath closed or not

How to check UIBezierPath is closed path or not (closed path is like closed contour means it creates any shape like triangle, square, polygon etc), and if it is closed then only fill in the path? The following represents the area where it should…
Bhargav Soni
  • 1,067
  • 1
  • 9
  • 22
3
votes
0 answers

Lines drawn using bezierPath and CAShapeLayer, not smooth

I have this code to draw lines on image user takes. I have successfully added feature to draw what ever the user feel like drawing on his/her image. But the lines which i draw is not smooth enough. I have tried the answers stack overflow experts…
Alex
  • 538
  • 3
  • 18
3
votes
4 answers

Apply CAShapeLayer to main UIView except UIButton

Here is a code which applying mask to the whole UIView: UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:self.view.bounds]; [maskPath appendPath:[UIBezierPath bezierPathWithArcCenter:self.mapCardsButton.center …
Serge
  • 2,031
  • 3
  • 33
  • 56
3
votes
1 answer

Drag and sacale a rectangle drawn using UIBezierPath IOS/Swift

I am developing a program which identifies a rectangle in an image and draws a path on the border of that identified rectangle. Now I want to reposition that path in case if it is not on the exact position. For an example look at this image In…
Hanushka Suren
  • 723
  • 3
  • 10
  • 32
3
votes
0 answers

CAShapeLayer poor scrolling performance. Why?

I have a single container view inside a UIScrollView, and that container view has several CAShapeLayer based subviews (about 200). Each CAShapeLayer contains a very simple CGPath (a filled polygon of about 10 points). You can see it as a sort of…
deadbeef
  • 5,409
  • 2
  • 17
  • 47
3
votes
2 answers

How to add a border to a circular image with mask

This is my attempt: func round() { let width = bounds.width < bounds.height ? bounds.width : bounds.height let mask = CAShapeLayer() mask.path = UIBezierPath(ovalInRect: CGRectMake(bounds.midX - width / 2, bounds.midY - width / 2, width,…
Adrian
  • 19,440
  • 34
  • 112
  • 219