作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
使用 Xcode v7.2 - iOS v9.2 - iPhone5S swift
我正在尝试创建一个透明的 UITextField
,带有浅灰色占位符文本。
我用过:
self.userEmailTextField.backgroundColor = UIColor.clearColor()
占位符文本消失,但在使用 whiteColor
或 blueColor
背景时出现。
白色背景:
清晰的背景:
最佳答案
由于背景颜色清晰,占位符不可见。您可以通过像这样设置占位符颜色来检查它...
在 swift ...
if let _ = self.placeholder{
self.txtField.attributedPlaceholder = NSAttributedString(string:self.placeholder!,
attributes:[NSForegroundColorAttributeName: UIColor.whiteColor()])
}
在目标语言中...
[textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
关于ios - 将 UITextField 背景设置为 .clearColor 时,为什么我的 UITextField 占位符会消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647627/
我是一名优秀的程序员,十分优秀!