How to change placeholder text color in xib?

牧云@^-^@ 提交于 2020-02-17 07:25:56

问题


How to change placeholder text color in xib ? I have tried key path thing but it is giving me NSException. Can anyone please help.


回答1:


The easiest method to modify the placeholder text color is through the Xcode storyboard interface builder. Select the UITextField of interest and open the identity inspector on the right. Click on the plus symbol in the User Defined Runtime Attributes and add a new row with Key Path as _placeholderLabel.textColor, Type as Color and Value to your desired color.




回答2:


Navneils answer with screenshot ,You can set opacity also from here




回答3:


We cannot change textcolor of placeholder text in storyboard. Manually we can change with the property name.

Addthis code in viewDidLoad

[nameTextField setValue:[UIColor colorWithRed:41.0/255.0 green:91.0/255.0 blue:106.0/255.0 alpha:1.0] forKeyPath:@"_placeholderLabel.textColor"];



回答4:


use placeholderLabel.textColor instead of _placeholderLabel.textColor for swift 5.0 and iOS 13



来源:https://stackoverflow.com/questions/23284621/how-to-change-placeholder-text-color-in-xib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!