在使用我的应用程序时,我遇到了一些绘画方面的问题:
我想知道为什么,回到Obj,-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()发布于 2014-06-20 00:22:51
您正在使用rect初始化bezier路径,因此rect是调用path.stroke()时会被抛出的路径的一部分。您可以将路径初始化为NSBezierPath()。
发布于 2014-06-19 20:56:23
我建议,与其使用NSBezierPath、NSColor和NSPoint,不如分别使用更新的UIBezierPath、UIColor和CGPoint。
https://stackoverflow.com/questions/24314673
复制相似问题