Questions tagged [uibezierpath]

The UIBezierPath class lets you define a path consisting of straight and curved line segments and render that path in your custom views.

The UIBezierPath class lets you define a path consisting of straight and curved line segments and render that path in your custom views. You use this class initially to specify just the geometry for your path. Paths can define simple shapes such as rectangles, ovals, and arcs or they can define complex polygons that incorporate a mixture of straight and curved line segments. After defining the shape, you can use additional methods of this class to render the path in the current drawing context.

Its counterpart in OS X is .

Resources:

1777 questions
22
votes
2 answers

Making UIBezierPath more like NSBezierPath with elementCount and elementAtIndex

When moving some Cocoa code to Cocoa Touch I was disappointed to find that UIBezierPath is missing the "Accessing Elements of a Path" methods: – elementCount – elementAtIndex: – elementAtIndex:associatedPoints: – removeAllPoints –…
EFC
  • 1,890
  • 18
  • 39
22
votes
2 answers

Represent CIRectangleFeature with UIBezierPath - Swift

Currently I am using a CIDetector to detect rectangles in my UIImage. I am doing the suggested way in which you pass the coordinates into a filter to get back a CIImage to put over the taken UIImage. It looks like this: func…
John55
  • 301
  • 2
  • 11
22
votes
2 answers

Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?

I'm creating a CAShapeLayer to use as a mask for a UIView's layer. I'm using a UIBezierPath to draw the shape layer. It's working fine, except I'm getting some odd results when I draw. The geometry is not behaving as expected. I'm trying to draw…
zakdances
  • 22,285
  • 32
  • 102
  • 173
21
votes
2 answers

How does usesEvenOddFillRule work?

Can anybody explain how the usesEvenOddFillRule property of UIBezierPath works and where it can be used? I know I may get Vote downs but I really didn't get the explanation in Apple's docs.
Developer
  • 6,375
  • 12
  • 58
  • 92
20
votes
2 answers

Using UIBezierPath:byRoundingCorners: with Swift 2 and Swift 3

I'm using this code to make 2 corners of a button rounded. let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: .TopLeft | .BottomLeft, cornerRadii:…
sanjihan
  • 5,592
  • 11
  • 54
  • 119
20
votes
5 answers

How to add rounded corner to a UIBezierPath custom rectangle?

I managed to create the rounded corners, but I'm having trouble with the first rounded corner (lower right ) Question : Can I add an (addArcWithCenter) method before the ( moveToPoint ) method ? How can i get rid of the straight line at the…
AziCode
  • 2,510
  • 6
  • 27
  • 53
20
votes
10 answers

Draw Graph curves with UIBezierPath

I'm drawing a graph in my application. My problem is that I want to draw line joining vertex points as curves. Currently I'm drawing them with UIBezierPath's function addLineToPoint:. I want to draw them as curves. I'm well aware that UIBezierPath…
Abid Hussain
  • 1,529
  • 1
  • 15
  • 33
20
votes
3 answers

CABasicAnimation with CALayer path doesn't animate

I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft |…
eric.mitchell
  • 8,817
  • 12
  • 54
  • 92
19
votes
2 answers

How to change the color of a UIBezierPath in Swift?

I have an instance of UIBezierPath and I want to change the color of the stroke to something other than black. Does anyone know how to do this in Swift?
bhzag
  • 2,932
  • 7
  • 23
  • 39
18
votes
2 answers

How to draw Bezier curves with native Javascript code without ctx.bezierCurveTo?

I need to draw and get coordinates of bezier curves of each steps with native Javascript without ctx.bezierCurveTo method. I found several resources, but I confused. Esspecially this looks pretty close, but I couldnt implemented clearly. How can I…
Digerkam
  • 1,826
  • 4
  • 24
  • 39
17
votes
3 answers

UIBezierPath doesn't work in TopRight corner and BottomRight corner

I want to round my right corners, but only works for Left corners let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.TopLeft, UIRectCorner.TopRight], cornerRadii: CGSizeMake(20.0, 20.0)) let maskLayer =…
Diego Quiroz
  • 191
  • 2
  • 7
17
votes
8 answers

How to draw heart shape in UIView (iOS)?

I want to create different shapes. Below image is the one of example. Will you suggest me how to different shapes?
Rajesh Maurya
  • 3,026
  • 4
  • 19
  • 37
17
votes
2 answers

Draw gradient along a curved UIBezierPath

In an app, I draw a curved UIBezierPath an an MKOverlayPathView class to show flight routes. This is the code I am using: - (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { ... bla bla bla ... UIBezierPath *path =…
freshking
  • 1,824
  • 18
  • 31
17
votes
1 answer

Animating a circular UIBezierPath

I've got a project where I'm animating a UIBezierPath based on a set progress. The BezierPath is in the shape of a circle and lies in a UIView and animation is done in drawRect using CADisplayLink right now. Simply put, based on a set progress x the…
hav
  • 373
  • 5
  • 10
16
votes
5 answers

How to fill a CAShapeLayer with an angled gradient

How do I fill a CAShapeLayer() with a gradient and on an angle of 45 degrees? For example, in Image 1, the below code draws a square and fills the layer blue (UIColor.blueColor().CGColor). But, how do I fill it with a gradient on a 45 degree angle…
user4806509
  • 2,925
  • 5
  • 37
  • 72