美文网首页iOS倒计时
swift修改UITextfield的Placeholder字体

swift修改UITextfield的Placeholder字体

作者: 铁汁红豆 | 来源:发表于2023-02-12 15:27 被阅读0次

第一种方法:

self.userNumber.setValue(UIColor.lightGray, forKey: "_placeholderLabel.textColor")

self.userNumber.setValue(UIFont.systemFont(ofSize: 15), forKeyPath: "_placeholderLabel.font")

第二种方法:

  //字体大小

  textField.attributedPlaceholder = NSAttributedString.init(string:"输入你需要的服务", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize:15)])

  //字体颜色

  textField.attributedPlaceholder = NSAttributedString.init(string:"输入你需要的服务", attributes: [

  NSForegroundColorAttributeName:UIColor.red])

相关文章

网友评论

    本文标题:swift修改UITextfield的Placeholder字体

    本文链接:https://www.haomeiwen.com/subject/asedkdtx.html