UITextField
有一個(gè)重要的屬性placeholder
,一般情況下能滿足我們的需求。但是有時(shí)候我也也許會(huì)想要修改placeholder
的文本顏色辨液,此時(shí)就需要通過修改它的attributedPlaceholder
來實(shí)現(xiàn)吐咳。
廢話不多說,直接上代碼:
UITextField *heightTF = [[UITextField alloc] init];
heightTF.placeholder = @"請(qǐng)輸入內(nèi)容";
heightTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:heightTF.placeholder attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];