Skip to content

Instantly share code, notes, and snippets.

@cathandnya
Created April 3, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cathandnya/b89f4a7f0ebe19c4a27c75c84b01c556 to your computer and use it in GitHub Desktop.
Save cathandnya/b89f4a7f0ebe19c4a27c75c84b01c556 to your computer and use it in GitHub Desktop.
import Cocoa
class AutoGrowingTextField: NSTextField {
override var intrinsicContentSize: NSSize {
let size = super.intrinsicContentSize
var r = frame
r.size.height = 10000
if let h = cell?.cellSize(forBounds: r).height {
return NSSize(width: size.width, height: h)
} else {
return size
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment