简体   繁体   English

NSTextField 文本颜色

[英]NSTextField Text Color

Probably a newbie question (I'm a hobbyist, not a programmer) but I can't figure out how to change the text colour for a NSTextField.可能是新手问题(我是业余爱好者,不是程序员)但我不知道如何更改 NSTextField 的文本颜色。 I have such a field that is inactive still a certain event occurs, then I want to display a prompt red text prompt in the field then change the text colour to black so that when the user enters the info it appears in black.我有一个不活动的字段仍然发生某个事件,然后我想在该字段中显示一个提示红色文本提示,然后将文本颜色更改为黑色,以便当用户输入信息时它显示为黑色。 Can this be done?这能做到吗? Thanks, Keith谢谢,基思

This code would set your UITextField color to red.此代码会将您的 UITextField 颜色设置为红色。

[yourTextfield setTextColor:[UIColor redColor]];

When your event occurs you can use the same syntax to set it back to blackColor.当您的事件发生时,您可以使用相同的语法将其设置回 blackColor。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM