Changing Placeholder Text Color with Swift

前端 未结 30 2480
独厮守ぢ
独厮守ぢ 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:07

    For Objective C:

    UIColor *color = [UIColor colorWithRed:0.44 green:0.44 blue:0.44 alpha:1.0];
     emailTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Friend's Email" attributes:@{NSForegroundColorAttributeName: color}];
    

    For Swift:

    emailTextField.attributedPlaceholder = NSAttributedString(string: "Friend's Email",
                                 attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
    

提交回复
热议问题