Questions tagged [cgpath]

A graphics path is a mathematical description of a series of shapes or lines. CGPath defines an opaque type that represents an immutable graphics path.The issue related with this tag can be tagged using [tag:CGPath] in iOS

CGPath is available in apple "CoreGraphics" framework.CGPaths are how CoreGraphics describes the bezier paths it uses for drawing to the screen. They can go a long way to unlocking some of the power of CoreGraphics.

For More information:

CGPath related question in SO:

Related Tags:

446 questions
18
votes
2 answers

Is it possible to play a path backwards in a CAKeyFrameAnimation?

I want to animate the position of a CALayer based on a CGPath, but I want to play it backwards. Is there any way to animate a path backwards, or reverse a CGPath?
Alex
17
votes
2 answers

Draw glow around inside edge of multiple CGPaths

If I create a CGMutablePathRef by adding together two circular paths as shown by the left image, is it possible to obtain a final CGPathRef which represents only the outer border as shown by the right image? Thanks for any help!
dmarnel
  • 4,436
  • 1
  • 15
  • 11
17
votes
1 answer

1. CGPathMoveToPoint' is unavailable: Use move(to:transform:) 2. 'CGPathAddLineToPoint' is unavailable: Use addLine(to:transform:)

I have created one of my application in swift 2 in Xcode 7.3.1. But now I have open same application in Xcode 8.0 and perform changes. Some automatic changes are done and some errors and suggestions shown I have corrected them. But I am facing issue…
VRAwesome
  • 4,721
  • 5
  • 27
  • 52
17
votes
4 answers

Equivalent of or alternative to CGPathApply in Swift?

In the pre-release documentation there appears to be no Swift version of CGPathApply. Is there an equivalent or alternative? I'm trying to get all subpaths of a CGPath so that I can redraw it from a different starting point.
JuJoDi
  • 14,627
  • 23
  • 80
  • 126
17
votes
2 answers

Merge multiple CGPaths together to make one path

I am making a complex shape using a few CGRects and Ellipses. I would like to stroke that path once it has been created. When I stroke the path it strokes each shape. Is there a way I can merge each shape into a single path, so the stroke doesn't…
brenjt
  • 15,997
  • 13
  • 77
  • 118
16
votes
1 answer

Setting correct frame of a newly created CAShapeLayer

In short: Apple does NOT set the frame or bounds for a CAShapeLayer automatically (and Apple HAS NOT implemented an equivalent of [UIView sizeThatFits]) If you set the frame using the size of the bounding-box of the path ... everything goes wrong.…
Adam
  • 32,900
  • 16
  • 126
  • 153
15
votes
5 answers

How to draw polygons with CGPath?

I have been reading thru the documentation however it is not immediatly clear to me how to draw a polygon using CGPath. All I need to do is to draw CGPath around something like this: __ \ \ \ \ \__\ Could anyone please provide an snippet on…
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
15
votes
1 answer

Get CGPath total length

I have many UIBezierPath that I am animating with CALyerAnimation @"StrokeStart" and @"strokeEnd". I wish that the animation will have the same speed for all the paths so I thougt I might use the length of the path in : DISTANCE / TIME = SPEED Is…
shannoga
  • 19,649
  • 20
  • 104
  • 169
14
votes
5 answers

Performance when frequently drawing CGPaths

I am working on an iOS App that visualizes data as a line-graph. The graph is drawn as a CGPath in a fullscreen custom UIView and contains at most 320 data-points. The data is frequently updated and the graph needs to be redrawn accordingly – a…
Andi Wagner
  • 310
  • 2
  • 9
14
votes
1 answer

How to create a path using MKOverlayPathView?

I've been looking at Apple's iOS Class Reference documentation, and am unfortunately none the wiser. I have downloaded their sample code KMLViewer but they've overcomplicated it... All I really want to know is how to generate a path and add it to…
jowie
  • 8,028
  • 8
  • 55
  • 94
13
votes
4 answers

Frame and Bounds of CAShapeLayer

I am working on CAShapeLayer.And trying to draw non-linear path.I want to set frame to CAShapeLayer.So i can use CGPathGetPathBoundingBox method to get frame from CGPathRef. Here is code : CGMutablePathRef path =…
h999
  • 395
  • 1
  • 5
  • 21
13
votes
3 answers

Scale CGPath to Fit UIVIew

I need to know how I can scale down or up CGPath so it can fit UIView? Set the background color to yellow, To see the view clearly self.frame = CGRectMake(0, 0, 181, 154); self.backgroundColor = [UIColor yellowColor]; Draw CAShapeLayer CAShapeLayer…
MAMN84
  • 1,400
  • 2
  • 13
  • 22
12
votes
3 answers

Reposition CGPath/UIBezierPath in View

How can I update position of an already drawn CGPath/UIBezierPath on a view? I would like to move or change a path's position and then perhaps call the drawInRect method to just render the path again.
SleepNot
  • 2,982
  • 10
  • 43
  • 72
11
votes
1 answer

What do the parameters to CGPathAddCurveToPoint mean?

I want to build a CGPathRef programatically based on the coordinates of the Sun at different points of the day. Calculating the points is not a problem, but I want to make a CGPathRef that is smooth and thought CGPathAddCurveToPoint would be…
Steve
  • 6,332
  • 11
  • 41
  • 53
11
votes
1 answer

Troubles using CGPathContainsPoint SWIFT

I need to check if a CGPoint is inside a SKSpriteNode. After a little research, CGPathContainsPoint seems appropriated for my purpose. if CGPathContainsPoint(my_sprite_path, nil, my_point, false) { } But Xcode alerts me: Use of unresolved…
cmii
  • 3,556
  • 8
  • 38
  • 69
1
2
3
29 30