KMTextFieldCell.swift 613 B

123456789101112131415161718192021222324
  1. //
  2. // KMTextFieldCell.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by liujiajie on 2024/1/11.
  6. //
  7. import Cocoa
  8. class KMTextFieldCell: NSTextFieldCell{
  9. override func drawingRect(forBounds rect: NSRect) -> NSRect {
  10. var newRect:NSRect = super.drawingRect(forBounds: rect)
  11. let textSize:NSSize = self.cellSize(forBounds: rect)
  12. let heightDelta:CGFloat = newRect.size.height - textSize.height
  13. if heightDelta > 0 {
  14. newRect.size.height = textSize.height
  15. newRect.origin.y += heightDelta * 0.5
  16. }
  17. newRect.origin.x += 3
  18. return newRect
  19. }
  20. }