let view = NSTextView()
view.delegate = context.coordinator
view.string = text
view.font = NSFont.systemFont(ofSize: NSFont.systemFontSize*1.3, weight: .regular)
view.backgroundColor = NSColor(cgColor: CGColor(red: 0, green: 10, blue: 10, alpha: 10))!
NSTextView へ何かを施そうとするといちいち難しいので、備忘録です。
let view = NSTextView()
let font = NSFont.systemFont(ofSize: NSFont.systemFontSize*1.3, weight: .regular)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .left
paragraphStyle.firstLineHeadIndent = 0.0
paragraphStyle.lineSpacing = 8.0
let attributes: [NSAttributedString.Key: Any] = [
.font: font,
.paragraphStyle: paragraphStyle
]
let attrString = NSAttributedString(string: text, attributes: attributes)
view.textStorage?.append(attrString)