NSView+Layer.swift 596 B

123456789101112131415161718192021
  1. //
  2. // NSView+Layer.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/2/15.
  6. //
  7. import Foundation
  8. extension NSView {
  9. func border( _ color: NSColor = NSColor.km_init(hex: "#DFE1E5"), _ width: CGFloat = 1.0, _ cornerRaius: CGFloat = 4.0) {
  10. self.wantsLayer = true
  11. self.layer?.borderColor = color.cgColor
  12. self.layer?.borderWidth = width
  13. self.layer?.cornerRadius = cornerRaius
  14. }
  15. func backgroundColor(_ color: NSColor = NSColor.km_init(hex: "#FFFFFF")) {
  16. self.wantsLayer = true
  17. self.layer?.backgroundColor = color.cgColor
  18. }
  19. }