Skip to content

Instantly share code, notes, and snippets.

@towry
Created April 10, 2016 07:34
Show Gist options
  • Save towry/c83fef4d1000a1a10211b34723b6c901 to your computer and use it in GitHub Desktop.
Save towry/c83fef4d1000a1a10211b34723b6c901 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment