Skip to content

Instantly share code, notes, and snippets.

@sonburn
Created November 6, 2017 15:09
Show Gist options
  • Save sonburn/aa6d17566c0a38d8400ab8ebbd14e3d4 to your computer and use it in GitHub Desktop.
Save sonburn/aa6d17566c0a38d8400ab8ebbd14e3d4 to your computer and use it in GitHub Desktop.
function createViewWithImage(context,file,frame) {
var imageView = NSView.alloc().initWithFrame(frame),
imagePath = context.plugin.urlForResourceNamed(file).path(),
image = NSImage.alloc().initByReferencingFile(imagePath);
imageView.setWantsLayer(1);
imageView.layer().setBackgroundColor(CGColorCreateGenericRGB(255,255,255,1));
imageView.layer().contents = image;
return imageView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment