How to change UITextfield placeholder color and fontsize using swift 2.0?

前端 未结 10 688
小蘑菇
小蘑菇 2020-12-28 16:22

How to change UITextfield placeholder & fontsize in SWIFT 2.0?

10条回答
  •  -上瘾入骨i
    2020-12-28 16:44

    Updated for Swift 3

    If you want to change the UITextField Placeholder color for Swift 3, use the following lines of code:

    let yourTextFieldName = UITextField(frame: CGRect(x: 0, y: 0, width: 180, height: 21))
    yourTextFieldName.attributedPlaceholder = NSAttributedString(string: "placeholder text", attributes: [NSForegroundColorAttributeName: UIColor.white])
    

提交回复
热议问题