开发者

iphone ipad change text field colour

please, how can I change the color of the text field background and the colour of place holder? I saw this answer

here in stack, change bkgrnd but Is not clear where to call this

[UIColor colorWithRed:0.2f green:0.3f blue:0.4f alpha:0.50001f];

shall I override the UITextField.h? where? or where shall I change the colour?

and for the changing of the place holder,开发者_开发问答 but it doesn't work! stack, change holder.


You can overwrite UITextField and do this in the init method. But I would highly recommend to do simply after you created your UITextField

textField.backgroundColor = [UIColor colorWithRed:0.2f green:0.3f blue:0.4f alpha:0.50001f];


To change the background of your textfield :

  yourTextField.backgroundColor = [UIColor yellowColor];

To change the placeholder text color :

   [yourTextField setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜