mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
18 lines
414 B
Swift
18 lines
414 B
Swift
//
|
|
// NSView.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2019/6/18.
|
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import AppKit
|
|
|
|
extension NSView {
|
|
func image() -> NSImage {
|
|
let imageRepresentation = bitmapImageRepForCachingDisplay(in: bounds)!
|
|
cacheDisplay(in: bounds, to: imageRepresentation)
|
|
return NSImage(cgImage: imageRepresentation.cgImage!, size: bounds.size)
|
|
}
|
|
}
|