Changing Placeholder Text Color with Swift

前端 未结 30 2534
独厮守ぢ
独厮守ぢ 2020-11-29 15:57

I have a design that implements a dark blue UITextField, as the placeholder text is by default a dark grey colour I can barely make out what the place holder te

30条回答
  •  野性不改
    2020-11-29 16:04

    Objective C code for changing placeholder text color.

    First import this objc/runtime class -

    #import 

    then replace your textfield name -

    Ivar ivar =  class_getInstanceVariable([UITextField class], "_placeholderLabel");
    UILabel *placeholderLabel = object_getIvar(YourTxtField, ivar);
    placeholderLabel.textColor = [UIColor whiteColor];

提交回复
热议问题