私のアプリで作業していると、描画に関するいくつかの問題が発生しました。
なぜ、Obj-c に戻って、-moveToPoint()
問題-lineToPoint()
なくすべてを描画していたのか疑問に思っていました。もっと詳しく説明しましょう:
あなたの仕事が 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()