How to customize NSTextView in AppKit

Issue #320

Scrollable

textview

Embed image or NSTextAttachmentCellProtocol

  • Select TextView
  • Select Rich Text and Graphics
  • Select Size Inspector -> Resizable and tick both Horizontally and Vertically

Customize

1
2
3
4
5
6
7
8
9
10
11
12
13
14
scrollView.drawsBackground = false
textView.drawsBackground = false
textView.string = "What's on your mind?"
textView.delegate = self
textView.selectedTextAttributes = [
NSAttributedString.Key.backgroundColor: NSColor(hex: "414858"),
NSAttributedString.Key.foregroundColor: NSColor(hex: "ACB2BE")
]

extension MainView: NSTextViewDelegate {
func textViewDidChangeSelection(_ notification: Notification) {
// Change text color again after image dragging
}
}

Comments