towry
4/10/2016 - 7:34 AM

custom nsview class

custom nsview class

// put this in playground

class MyView : NSView {
    override func drawRect(dirtyRect: NSRect) {
        let pathRect = NSInsetRect(self.bounds, 1, 1)
        let path = NSBezierPath(roundedRect: pathRect, xRadius: 10, yRadius: 10)
        path.lineWidth = 4
        NSColor.greenColor().setFill()
        NSColor.blackColor().setStroke()
        path.fill()
        path.stroke()
    }
}

let viewRect = NSRect(x: 0, y: 0, width: 100, height: 100)
let myEmptyView = MyView(frame: viewRect)