2012-07-19 65 views
1

我想更改目标c 中的UItextfield占位符颜色,但我的类是uiviewcontroller的子类。 我可以继承uiviewcontroller和uitextfield吗?如何更改目标c占位符的颜色

+0

这是补救你的问题 [HTTP ://stackoverflow.com/questions/1340224/iphone-uitextfield-change-placeholder-text-color] [1] [1]:http://stackoverflow.com/questions/1340224/iphone-uitextfield-change-placeholder-text-color – Iducool 2012-07-19 08:08:39

回答

0
[self.Textfield setValue:[UIColor darkGrayColor] forKeyPath:@"_placeholderLabel.textColor”]; 
+0

我想这但不工作的,我的文本框是当地 – nuttekar 2012-07-19 07:58:34

+0

嘿它会工作....如果你只是想改变你的textfield占位符的颜色...只是用self.Textfield替换你的textField名称.. – TheTiger 2012-07-19 07:59:54

+0

嘿,Textfield意味着它是全局对象,我的文本字段是本地的 – nuttekar 2012-07-19 08:01:47

0

您需要继承的UITextField和ovveride的drawPlaceholderInRect方法

看看这个question

1

您可以使用波纹管代码

[yourtextfield setValue:[UIColor colorWithRed:120.0/255.0 green:116.0/255.0 blue:115.0/255.0 alpha:1.0] forKeyPath:@"_placeholderLabel.textColor"];