KMScrollView.swift 575 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // KMScrollView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2025/1/10.
  6. //
  7. import Cocoa
  8. class KMScrollView: NSScrollView {
  9. var contentViewSize: CGSize? = nil
  10. override func draw(_ dirtyRect: NSRect) {
  11. super.draw(dirtyRect)
  12. // Drawing code here.
  13. }
  14. override func layout() {
  15. super.layout()
  16. print(NSDate())
  17. if let value = contentViewSize {
  18. self.documentView?.frame = CGRectMake(0, 0, value.width, max(value.height, self.bounds.size.height))
  19. }
  20. }
  21. }