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
76
votes
7 answers

Drawing UIBezierPath on code generated UIView

I have a UIView added in code at run time. I want to draw a UIBezierPath in it, but does this means i have to override the drawRect for UIView? Or is there another way of drawing to it on the custom made UIView? Here is the code for generating the…
Itzik984
  • 15,968
  • 28
  • 69
  • 107
54
votes
9 answers

UIBezierPath Subtract Path

By using [UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:], I am able to create a rounded view, such as this: How could I subtract another path from this one (or some other way), to create a path like this: Is there any way I…
jadengeller
  • 1,307
  • 1
  • 14
  • 26
51
votes
12 answers

How to draw a "speech bubble" on an iPhone?

I'm trying to get a "speech bubble" effect similar to the one in Mac OS X when you right click on something in the dock. Here's what I have now: I need to get the "triangle" part of the lower portion. Is there any way I can draw something like…
sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
45
votes
7 answers

How to get a list of points from a UIBezierPath?

I have a UIBezierPath that I need to take a list of points from. In Qt there is a function called pointAtPercent that would fit my needs but I can't find anything equivalent in Objective-C. Does anyone know how to do this?
Alexandre
  • 807
  • 2
  • 9
  • 15
42
votes
4 answers

Draw a line with UIBezierPath

First time using BezierPaths, wondering how this function is actually supposed to be implemented. Currently the bezier path moves within the frame of the image, as opposed to drawing on screen. Is there a better way to do it? func…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
38
votes
3 answers

How to animate a human written stroke using Swift/iOS?

Objective I am attempting to create an animated approximation of human writing, using a UIBezierPath generated from a glyph. I understand and I have read the many UIBezierPath questions which sound similar to mine (but are not the same). My goal is…
Tommie C.
  • 12,895
  • 5
  • 82
  • 100
35
votes
2 answers

An easy way to draw a circle using CAShapeLayer

In questions like How to draw a smooth circle..., ...Draw Circle... and ...draw filled Circles the question and answer is very broad, contains lots of unnecessary steps and the methods used isn't always the easiest to re-create or manage. What is an…
Aleksander Azizi
  • 9,829
  • 9
  • 59
  • 87
32
votes
3 answers

Apply gradient color to arc created with UIBezierPath

I want to create a progress bar that has the form of an arc. The color of the progress bar has to change according to the values. I created an arc using UIBezierPath bezierPathWithArcCenter. I used the following code: - (void)viewDidLoad { …
Granit
  • 1,261
  • 6
  • 19
  • 35
29
votes
7 answers

UIBezierPath Triangle with rounded edges

I have designed the following code to generate a UIBezierPath. This path is used within a CAShapeLayer to mask a UIView. Note, the view's height and width are variable. This code generates a triangle with sharp edges, but I would like to make the…
H Bellamy
  • 22,405
  • 23
  • 76
  • 114
26
votes
5 answers

UIBezierPath: How to add a border around a view with rounded corners?

I am using UIBezierPath to have my imageview have round corners but I also want to add a border to the imageview. Keep in mind the top is a uiimage and the bottom is a label. Currently using this code produces: let rectShape =…
gooberboobbutt
  • 797
  • 2
  • 8
  • 19
26
votes
8 answers

How to crop the image using UIBezierPath?

I want to get the image from the UIBezierpath closed path(See the image). I draw the image on the UIView using drawRect method and also draw the lines are using the drawRect method. How can I get the particular closed path image? Please help me.…
Mani
  • 1,310
  • 1
  • 20
  • 40
26
votes
1 answer

How to Animate a UIBezierPath

i would like to animate a UIBezierPath of a rect to a triangle one, not to animate a view on a path but animate the path itself so it morphs from one shape to another. the path is added to a CALayer CAShapeLayer *maskLayer = [CAShapeLayer…
Yogev Shelly
  • 1,373
  • 2
  • 13
  • 24
25
votes
4 answers

Why is cornerRadii parameter of CGSize type in -[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]?

I can't figure this out... I'm playing with -[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] as such: bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 80, 80) …
Bartek Chlebek
  • 1,665
  • 1
  • 16
  • 23
24
votes
2 answers

What is the difference between CGPath and UIBezierPath()?

At the moment, I'm trying to work out how to animate a custom button which I have an image of and have the coordinates of but I've found that you can create a button/object both by using the CGPath class or the UIBezierPath class. Can somebody…
BrianCO
  • 261
  • 2
  • 3
23
votes
2 answers

UIBezierPath stroke 1px line and fill 1px width rectangle - different results.

Here is a simple drawing - (void)drawRect:(CGRect)rect { //vertical line with 1 px stroking UIBezierPath *vertLine = [[UIBezierPath alloc] init]; [vertLine moveToPoint:CGPointMake(20.0, 10.0)]; [vertLine…
Michael
  • 1,238
  • 2
  • 15
  • 26
1
2 3
99 100