1
我想使用此代码绘制在NSImageView铅笔条纹画在OSX铅笔条纹:使用SWIFT
class DrawView: NSImageView
{
var point = NSPoint()
override func drawRect(dirtyRect: NSRect)
{
let myContext = NSGraphicsContext.currentContext()?.CGContext
CGContextSetRGBStrokeColor (myContext, 1, 0, 0, 1)
CGContextAddArc(myContext, point.x, point.y,1,0.1,0,0)
CGContextSetLineWidth(myContext, 1)
CGContextStrokePath(myContext)
}
func MousePan(mouseLocation: NSPoint)
{
point = mouseLocation
self.setNeedsDisplay()
}
}
到目前为止,几乎所有的作品很好,我得到我的MousePointer一个红色的点作为只要我点击我的视图移动鼠标。 我的问题是,我没有看到我的观点的条纹,只是这个小红点。 我必须做些什么才能让这件事情起作用?
在此先感谢。