【发布时间】:2013-12-07 00:24:18
【问题描述】:
美好的一天!我只想问是否可以根据输入的值更改 UITextField 的背景颜色?或者我可以设置任何特定颜色的值吗? 例如我设置5,10,15,20红色和3,6,9,12绿色?我试过这段代码,但只针对单一颜色,我想根据我输入的值更改为,
case 0:
yy = self.txtTimestamp.frame.origin.y + self.txtTime.frame.size.height;
self.txtTimestamp.backgroundColor = [UIColor blackColor];
break;
case 1:
yy = self.txtTrucknumber.frame.origin.y + self.txtDrivername.frame.size.height;
//self.txtDrivername.backgroundColor = [UIColor blackColor];
break;
case 2:
yy = self.txtDrivername.frame.origin.y + self.txtClockin.frame.size.height;
//self.txtClockin.backgroundColor = [UIColor blackColor];
break;
case 3:
yy = self.txtSsn.frame.origin.y - self.txtTrucknumber.frame.size.height;
//self.txtTrucknumber.backgroundColor = [UIColor blackColor];
break;
case 4:
yy = self.txtClockin.frame.origin.y - self.txtTrucknumber.frame.size.height;
//self.txtTrucknumber.backgroundColor = [UIColor blackColor];
break;
【问题讨论】:
-
是的,你可以做到。但您需要先存储所有值,然后才使用输入值的条件。
-
你能提供一个好的样品吗?谢谢!
标签: ios uitextfield