2012-07-19 58 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"]; 
相關問題