Search code examples
swiftcosmicmind

Change colour of textView placeholder


I am using a material design library for ios but i didn't found any property on how to change it's placeholder colour when there is no data entered. I have to use a standard background and the placeholder is not visible if it's gray


Solution

  • You can use an attributed string for this:

    let attrString = NSAttributedString(string: "Text", attributes: [NSForegroundColorAttributeName:UIColor.blueColor()])
    myTextField.attributedPlaceholder = attrString