1.通過KVC設(shè)置默認文本的顏色
textField.placeholder=@"多個標簽用逗號或者換行隔開";
//設(shè)置了占位文字內(nèi)容以后,才能設(shè)置占位文字的顏色
[textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
2.通過UITextFiled<UITextInput>協(xié)議的方法
- (void)deleteBackward來監(jiān)聽鍵盤上刪除鍵的點擊
textField.hasText來監(jiān)聽有沒有內(nèi)容
3.[textField addTarget:selfaction:@selector(textDidChange) forControlEvents:UIControlEventEditingChanged];監(jiān)聽文字改變