我是目标-c的新手,我遇到问题,我有一个输入文件,我试图在用户在UITextField上开始输入时更改输入字段背景颜色 对于输入文件我的代码是下面的
SELECT GEOGRAPHY , PROJECT ,
CASE
WHEN project_name = 'test1'
THEN 'test1'
WHEN project_name = 'test2'
THEN 'test2'
WHEN project_name = 'test3'
AND test_NAME = 'samp1'
THEN 'gen1'
WHEN project_name = 'test3'
AND TEST_name <> 'samp1'
THEN 'gen2'
ELSE project_name
END PROJECT_NAME from table 1
group by
geography ,project_name,test_name.
提前致谢
答案 0 :(得分:2)
选项1,使用委托
设置viewController符合UITextfieldDelegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
textField.backgroundColor = [UIColor blueColor];
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
textField.backgroundColor = [UIColor whiteColor];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return true;
}
选项2,使用目标操作
[textfield addTarget:self action:@selector(textFieldBeginEditing:) forControlEvents:UIControlEventEditingDidBegin];
然后在函数中
-(void)textFieldBeginEditing:(UITextField *)textfield{
textfield.backgroundColor = [UIColor blueColor];
}