使用我的应用程序时,我遇到了绘制内容的一些问题:
我想知道为什么,回到Obj-c,-moveToPoint()
和-lineToPoint()
正在毫无问题地绘制所有东西,现在,除了出现一个奇怪的边界外,一切看起来都是一样的在我看来。让我解释一下:
想象一下,你的任务是画一条从A(0,0)到B(10,10)的基本线
我们都知道如何在obj-c中做到这一点,但很快我就会有新的东西:
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()
答案 0 :(得分:4)
您正在使用rect初始化贝塞尔曲线路径,因此当您调用path.stroke()时,rect是路径的一部分。您可以将路径初始化为NSBezierPath()。
答案 1 :(得分:-3)
我建议您使用更新的NSBezierPath
,NSColor
和{{1},而不是NSPoint
,UIBezierPath
和UIColor
。 } 分别。