答案 0 :(得分:1)
答案 1 :(得分:1)
最好这样做:
if ([self.textField respondsToSelector:@selector(setAttributedPlaceholder:)]) {
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.textField.placeholder attributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
}
答案 2 :(得分:0)
我遇到了同样的问题。事实证明,这与我将borderStyle
设置为UITextBorderStyleNone
无关。这是由于我将UITextField
子类化为仅在底部添加手动绘制的边框而未能在我的覆盖layoutSubviews
中调用超级实现而导致的。一旦我对其进行了排序,我的占位符文本又回来了。