在 iOS 开发中,可以通过以下方法来设置 UITextField 的 placeholder 颜色:

Objective-C 代码示例:

// 创建 UITextField 对象
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
// 设置 placeholder 文本
textField.placeholder = '请输入内容';
// 设置 placeholder 颜色
[textField setValue:[UIColor redColor] forKeyPath:'_placeholderLabel.textColor'];
// 将 UITextField 添加到视图中
[self.view addSubview:textField];

通过上述代码,可以将 UITextField 的 placeholder 文本颜色设置为红色。

iOS UITextField Placeholder 颜色设置 - Objective-C 代码示例

原文地址: https://www.cveoy.top/t/topic/oUJl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录