在OC中給placeholder設(shè)置顏色可以直接用KVC
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
但是在swift中這么寫(xiě)直接崩掉
所以找了另一種方法
let str = NSAttributedString(string: "輸入手機(jī)號(hào)", attributes: [NSForegroundColorAttributeName:UIColor.white])
phoneNumer.attributedPlaceholder = str
這樣就可以了試下吧