How to change placeholder text color in xib?

后端 未结 4 506
轮回少年
轮回少年 2021-02-02 12:13

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

相关标签:
4条回答
  • 2021-02-02 12:47

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

    0 讨论(0)
  • 2021-02-02 12:48

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

    0 讨论(0)
  • 2021-02-02 12:58

    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"];
    
    0 讨论(0)
  • 2021-02-02 12:59

    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.

    0 讨论(0)
提交回复
热议问题