1、設(shè)置TextField的占位符顯示placeholder_attributedPlaceholder
// 文字屬性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
// NSAttributedString : 帶有屬性的文字(富文本技術(shù))
NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:@"手機(jī)號(hào)" attributes:attrs];
self.phoneField.attributedPlaceholder = placeholder;
// NSMutableAttributedString *placehoder = [[NSMutableAttributedString alloc] initWithString:@"手機(jī)號(hào)"];
// [placehoder setAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} range:NSMakeRange(0, 1)];
// [placehoder setAttributes:@{
// NSForegroundColorAttributeName : [UIColor yellowColor],
// NSFontAttributeName : [UIFont systemFontOfSize:30]
// } range:NSMakeRange(1, 1)];
// [placehoder setAttributes:@{NSForegroundColorAttributeName : [UIColor redColor]} range:NSMakeRange(2, 1)];
// self.phoneField.attributedPlaceholder = placehoder;