Is there any way to set the placeholder string for NSTextView
like that in NSTextField
? I have checked the property but couldn't find it. I have searched some questions but there isn't a proper explanation.
Is there any way to set the placeholder string for NSTextView
like that in NSTextField
? I have checked the property but couldn't find it. I have searched some questions but there isn't a proper explanation.
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.