swift修改UITextfield的Placeholder字体大小和颜色


 

第一种方法:

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

  

第二种方法:

  //字体大小
  textField.attributedPlaceholder = NSAttributedString.init(string:"输入你需要的服务", attributes: [NSFontAttributeName:UIFont.systemFont(ofSize:15)])
  //字体颜色
  textField.attributedPlaceholder = NSAttributedString.init(string:"输入你需要的服务", attributes: [
  NSForegroundColorAttributeName:UIColor.red])

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM