SwiftでUITextfieldのプレースホルダーのフォントサイズと色を変更します



Swift Modify Uitextfields Placeholder Font Size

**//最初 **

let textField = UITextField.init() textField.placeholder = placehold //font size textField.setValue(UIFont.systemFont(ofSize: 15),forKeyPath: '_placeholderLabel.font') //font color textField.setValue(UIFont.systemFont(ofSize: 15), forKeyPath: '_placeholderLabel.textColor')

//秒



//font size textField.attributedPlaceholder = NSAttributedString.init(string:'Enter the service you need', attributes: [NSFontAttributeName:UIFont.systemFont(ofSize:15)]) //font color textField.attributedPlaceholder = NSAttributedString.init(string:'Enter the service you need', attributes: [ NSForegroundColorAttributeName:UIColor.red])