iOS 开发 uitextfield placeholder颜色 oc代码
在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文本颜色设置为红色。
原文地址: https://www.cveoy.top/t/topic/i1eT 著作权归作者所有。请勿转载和采集!