Reputation: 2547
I am developing a Cocoa app with Swift and using a NSTextField in order to let users to enter text.
I have also set a attributed placeholder string to this text field with following code:
MyTextField.placeholderAttributedString = NSAttributedString(string: "my placeholder text", attributes: [NSForegroundColorAttributeName:RGB(16, g: 105, b: 125, alpha: 0.5), NSFontNameAttribute:"Roboto-Medium", NSFontSizeAttribute:14])
and everything is fine about showing attributed placeholder string until I click on the text field.
When the user clicked on the field, the placeholder size changes to a smaller font by itself.
Any advices to avoid this will be appreciated...
Upvotes: 1
Views: 602
Reputation: 2547
Answering my own question.
The problem is solved when I set the attributed placeholder text as below.
MyTextField.placeholderAttributedString = NSAttributedString(string: "my placeholder text", attributes: [NSForegroundColorAttributeName:RGB(16, g: 105, b: 125, alpha: 0.5),NSFontAttributeName:NSFont(name: "Roboto-Medium", size: 14.0)!])
I hope it helps someone...
Upvotes: 1