我只是想更改文本字段的占位符字体大小。我已经尝试了一些互联网解决方案,但失败了。但是我很容易更改了占位符字体颜色。
textField?.frame = CGRect.init(x: 5, y: 10, width: self.frame.size.width-10, height: gap/2+10)
textField?.minimumFontSize = 10
textField?.adjustsFontSizeToFitWidth = true
textField?.textAlignment = NSTextAlignment.center
textField?.textColor = TextColor;
let attributes = [
NSAttributedStringKey.foregroundColor: UIColor.red,
NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 10.0)
]
textField?.allowsEditingTextAttributes = true
textField?.attributedPlaceholder = NSAttributedString(string: "Enter Number", attributes:attributes)
字体大小没有影响,为什么?