NSBezierPath is a class responsible for constructing and drawing paths in Cocoa.
Questions tagged [nsbezierpath]
150 questions
1
vote
2 answers
How to fix convenience init w/closure Extension of NSBezierPath to use CGPath that fails in Swift 5.0?
Inline below is is a method I acquired somewhere for extending NSBezierPath using a convenience initializer that takes CGPath as an argument so that it behaves more like UIBezierPath on iOS.
It worked previously, but when I try to compile it (years…

clearlight
- 12,255
- 11
- 57
- 75
1
vote
2 answers
Force Custom NSView from PaintCode to Redraw
I created an icon in PaintCode that is drawn programmatically (but this question isn't necessarily specific to that tool) and I'm trying to get that icon to redraw.
I use a custom class like this:
class IconTabGeneral: NSView {
override func…

Clifton Labrum
- 13,053
- 9
- 65
- 128
1
vote
2 answers
Storing bezier paths in Core Data for Mac OS X and iOS
I am developing an iOS application that comes pre-loaded with CoreData content.
I am trying to create an importer app for the Mac OS X command-line which uses the same xcdatamodel and imports the initial data that I can ship with the actual app.
So…

Raphael Schweikert
- 18,244
- 6
- 55
- 75
1
vote
3 answers
Draw a Point using NSBezierPath
I want to create a single pixel-size dot. I assumed the way to do so was to draw a line using NSBezierPath with the starting point being equal to the end point (see code below) but doing so makes a completely empty window.
func drawPoint() {
…

Parankush Bhardwaj
- 27
- 5
1
vote
1 answer
MacOS does not display NSBezierPath line
I'm trying to draw a line in my MacOS app but I do not see the line. What can be a problem?
My code looks like:
func addLine() {
let path = NSBezierPath()
path.move(to: NSPoint(x: 100.0, y: 100))
path.line(to: NSPoint(x: 200.0, y:…

J. Doe
- 521
- 4
- 15
1
vote
0 answers
Accessing elements of a NSBezierPath
I am just starting to learn how to work with NS-classes.
Right now I am trying to figure out how it is possible to index through and access certain parts of a NSBezierPath.
In the snippet below there is a circular path that has 12 nodes and 4…

NewbCake
- 433
- 2
- 7
- 22
1
vote
0 answers
How to use Bezier Path to change UIImage to a marker shape?
I need to change the shape of a UIImage to that of a marker. I tried to combine 2 UIImages but the result was not sufficient. Is Bezier Path, a useful solution in such a case?
This will be a sample shape to which I need to convert my UIImage.

Sidharth J Dev
- 927
- 1
- 6
- 25
1
vote
0 answers
How to add NSBezierPath to CALayer in Swift for Mac OS?
I am coding in Swift. And I am writing a Mac OS app. I have created an NSBezierPath, now I want to add it my layer (CALayer)? How do you do that?
let myShape = NSBezierPath()
myShape.appendBezierPathWithArcWithCenter(centrePoint,…

Anna-Lischen
- 856
- 1
- 16
- 35
1
vote
1 answer
Can't display an UIBezierPath
I'm trying to display an UIBezierPath in a view. That's the object:
let color = UIColor(red: 0.651, green: 1.000, blue: 0.000, alpha: 1.000).setFill()
let rectanglePath = UIBezierPath(rect: CGRectMake(15, 0, 8, 120))
rectanglePath.fill()
but, when…

Matte.Car
- 2,007
- 4
- 23
- 41
1
vote
1 answer
Simplifying NSBezierPath (Or UIBezierPath) code, How?
theLen = [NSBezierPath bezierPath];
[theLen moveToPoint:NSMakePoint(_frame.size.width/2 + base / 2 , _frame.size.height/2 - (diameter / 2))];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 - base / 2 , _frame.size.height/2 - (diameter /…

31i45
- 315
- 1
- 2
- 12
1
vote
1 answer
Cocoa Drawing Error: "invalid context 0x0"
I'm trying to draw some sweet squares on my window view, but I get some strange errors. Am I doing something wrong?
Here's the code:
import Foundation
import AppKit
public class MyWindowView: NSView {
private func drawARectAtPoint(point: NSPoint)…

Andi Utzinger
- 63
- 7
1
vote
2 answers
UIBezierPath draw rectangle and arcs together
I want to draw one path like this:
and this is what I wrote :
CGFloat radius = 50;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(radius, CGRectGetMinY(rect))];
[path addLineToPoint:CGPointMake(CGRectGetMaxX(rect) -…

LiMo
- 65
- 1
- 8
1
vote
2 answers
Swift & NSBezierPath
Working with my app, i encountered some issues with drawing stuff:
I was wondering why, back to Obj-c, -moveToPoint() and -lineToPoint() were drawing everything with no problem and now, with swift, everything seems the same except for a strange…

Alberto
- 4,212
- 5
- 22
- 36
1
vote
1 answer
Array of NSBezierPaths returns 'plist cannot contain CFType' error on save
I have an array of NSBezierPath objects that essentially represent all the strokes the user makes in my basic paint application. However, when trying to create an NSData object (plist containing the array) in dataOfType:error: the app gives me the…

PopKernel
- 4,110
- 5
- 29
- 51
1
vote
3 answers
How to create a dynamic rectangle on uiimage in ios?
i am trying to crate a dynamic rectangle on imageview. it means rectangle should start on the touch and as long as user move the touch it should be bigger in that direction.
friend suggest me, please.

Mohit Tomar
- 5,173
- 2
- 33
- 40