我想在我的UITextField中设置我的文本的颜色。 textborder是黑色的,但里面的颜色是透明的。我如何给它添加颜色?UITextField文本颜色透明
以下是我有:
let memeTextAttributes:[String:Any] = [
NSStrokeColorAttributeName: UIColor.black,
NSForegroundColorAttributeName: UIColor.white,
NSFontAttributeName: UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSStrokeWidthAttributeName: 3.0]
topText.delegate = self
topText.defaultTextAttributes = memeTextAttributes
topText.text = "TOP"
topText.textAlignment = NSTextAlignment.center
topText.adjustsFontSizeToFitWidth = true
topText.center.x = self.view.center.x
topText.center.y = self.view.frame.origin.y + 150
topText.minimumFontSize = 10
topText.textColor = UIColor.white
1.不要同时设置'defaultTextAttirbutes'和'textColor'。 2.默认情况下,文本字段的背景为白色,因此您背景上的白色填充文本可能会使其显示为透明。 – rmaddy
好吧,我删除了textColor语句,但没有帮助。谢谢,还有其他建议吗? – ryanwaite28
你读过我的第二点了吗? – rmaddy