【发布时间】:2014-06-03 15:39:27
【问题描述】:
我已尝试将 UITextField "Placeholder" 颜色设置为深色。
NSAttributedString * search = [[NSAttributedString alloc] initWithString:@"Search" attributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}];
textField.attributedPlaceholder = search;
但
UITextField在“占位符”中仍显示为浅灰色。是否可以为
UITextField设置深色“占位符”颜色?
我也试过另一种方法
[textField setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
但这两种方法都适用于 iOS 7,但不适用于 iOS 6。
- 是否可以在 iOS 6 目标中为
UITextField设置深色 "placeholder" 颜色?
谢谢!
【问题讨论】:
-
您发布的代码应该可以工作 - 它对我有用。确保在此之后没有设置常规
placeholder属性的调用。调用代码时还要确保textField不是nil。
标签: ios objective-c uitextfield placeholder