Changing Placeholder Text Color with Swift

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

    Swift 4 :

    txtControl.attributedPlaceholder = NSAttributedString(string: "Placeholder String...",attributes: [NSAttributedStringKey.foregroundColor: UIColor.gray])
    

    Objective-C :

    UIColor *color = [UIColor grayColor];
    txtControl.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Placeholder String..." attributes:@{NSForegroundColorAttributeName: color}];
    

提交回复
热议问题