为什么不能更改文本字段占位符的文本字体大小?

时间:2020-04-23 13:37:50

标签: swift uitextfield placeholder

我只是想更改文本字段的占位符字体大小。我已经尝试了一些互联网解决方案,但失败了。但是我很容易更改了占位符字体颜色。

    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)

字体大小没有影响,为什么?

0 个答案:

没有答案
相关问题