Reputation: 3092
I'm using a textView with "Rich Text" option disabled to display some plain text. I can't find a way to set the default font. If I put in some text in IB (which I don't want anyway) I can then set the font in IB interface, but when users delete the font and start to type, the text changes to a different font and size. I read some questions and answers here and developer documentation without find a solution.
Upvotes: 2
Views: 1969
Reputation: 3158
If you know the exact name of the font you want to use, like for this case "AvenirNextCondensed"
let tv = NSTextView()
tv.font = NSFont(name: "AvenirNextCondensed-Regular", size: 15.0)!
If you want to use the system font of size whatever, do it like this (where size
is a CGFloat
)
tv.font = NSFont.systemFont(ofSize: size)
Upvotes: 6