使用我的应用程序时,我遇到了一些绘图问题:
我想知道为什么,回到 Obj-c,-moveToPoint()
并且-lineToPoint()
毫无问题地绘制所有内容,现在,使用 swift,除了出现在我的视图上的奇怪边框之外,一切似乎都一样。让我更好地解释一下:
想象一下,你的任务是画一条从 A(0,0) 到 B(10,10) 的基本线
我们都知道如何在 obj-c 中做到这一点,但在 swift 中我发现了一些新东西:
var path : NSBezierPath = NSBezierPath(rect: dirtyRect)
let color = NSColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
color.set()
path.moveToPoint(NSPoint(x: 0,y: 0))
path.lineToPoint(NSPoint(x: 10,y: 10))
path.lineWidth = 5.0 //Makes the line 5px width, but it even
//creates an annoying border along the view
//Try it out, i can't figure out how to get rid of it
path.stroke()