mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-12 17:54:05 +01:00
30 lines
527 B
Swift
30 lines
527 B
Swift
//
|
|
// NSImage+RSCore.swift
|
|
// RSCore
|
|
//
|
|
// Created by Brent Simmons on 12/16/17.
|
|
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
#if os(macOS)
|
|
import AppKit
|
|
|
|
public extension NSImage {
|
|
|
|
func tinted(with color: NSColor) -> NSImage {
|
|
|
|
let image = self.copy() as! NSImage
|
|
|
|
image.lockFocus()
|
|
|
|
color.set()
|
|
let rect = NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
|
|
rect.fill(using: .sourceAtop)
|
|
|
|
image.unlockFocus()
|
|
|
|
image.isTemplate = false
|
|
return image
|
|
}
|
|
}
|
|
#endif
|