画一条垂直线

时间:2017-03-03 08:13:10

标签: macos swift3 draw

我想在我的状态栏应用中放置一个图像(我将创建),这个图像应该是垂直线,但我现在不知道如何绘制它们。

1 个答案:

答案 0 :(得分:0)

实测值

let graphWidth: CGFloat = 22.0;
let graphHeight: CGFloat = 22.0
let size = NSMakeSize( graphWidth, graphHeight )
let image = NSImage(size: size)
image.lockFocus()

let path = NSBezierPath()
path.move(to: NSPoint(x: 20.0, y: 0))
path.line(to: NSPoint(x: 20.0, y: 20.0))
path.stroke()
image.unlockFocus()

statusItem.image = image