美文网首页
iOS开发UITextField

iOS开发UITextField

作者: lczalh | 来源:发表于2017-08-24 19:05 被阅读3次

设置占位符颜色

// 设置了占位文字内容以后, 才能设置占位文字的颜色
[textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];

设置消息中心,监听值的改变

//监听textFiel的值时时改变
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(textFieldDidChangeValue:)
                                                 name:UITextFieldTextDidChangeNotification
                                               object:self.bodyValueTextField];


- (void)dealloc {

    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

相关文章

网友评论

      本文标题:iOS开发UITextField

      本文链接:https://www.haomeiwen.com/subject/xhoedxtx.html