-1

如何在 Swift 4 中更改 UITextfield 占位符的颜色?似乎是一项简单的任务,但由于我是新的编程和 Swift,我很难弄清楚。我想以编程方式更改颜色。

        tf.placeholder = "Name"
        tf.translatesAutoresizingMaskIntoConstraints = false
        UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.thin)
4

1 回答 1

3
someTextField.attributedPlaceholder = NSAttributedString(string: "Placeholder text", attributes: [NSAttributedStringKey.foregroundColor: UIColor.red])
于 2018-03-13T22:34:44.400 回答