Swift 4
As it turns out, there already seems to be a placeholderAttributedString
property in NSTextView
that isn't exposed publicly. Thus, you can simply implement it in your own subclass and get the default placeholder behaviour (similar to NSTextField
).
class PlaceholderTextView: NSTextView {
@objc var placeholderAttributedString: NSAttributedString?
}
And if this property will be made available in the future, you only need to use NSTextView instead of this subclass.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…